stats

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package stats computes the figures of the admin overview and the home page's totals. Everything is counted in the database (Blessing Skin loaded a month of rows into PHP to draw its chart).

Index

Constants

View Source
const Days = 31

Days is how many days the overview chart covers, today included (as Blessing Skin).

Variables

This section is empty.

Functions

func Storage

func Storage(ctx context.Context, db *ent.Client) (files int, bytes int64, err error)

Storage counts the stored files (equal images share one) and their total size.

Types

type Day

type Day struct {
	Date          string // YYYY-MM-DD
	Registrations int
	Uploads       int
}

Day is one day of the chart, in the site's time zone.

type Overview

type Overview struct {
	Users, Players, Textures, PublicTextures, ClosetItems int
	Files                                                 int   // stored files (shared by equal images)
	StorageBytes                                          int64 // their total size
	PendingReports                                        int
	Days                                                  []Day // oldest first
}

Overview is the admin overview.

func Compute

func Compute(ctx context.Context, db *ent.Client, now time.Time, loc *time.Location) (*Overview, error)

Compute counts everything for the overview. Each day of the chart is two range counts on indexed created_at columns, with day boundaries taken in loc, so the queries are the same on every database and daylight saving time is handled. The bounds are passed in the server's zone, the one created_at is written in (time.Now): SQLite compares times as the stored text, which orders correctly only within one zone.

type Totals

type Totals struct {
	Users, Players, PublicTextures int
}

Totals are the public figures of the home page's stats block.

func CountTotals

func CountTotals(ctx context.Context, db *ent.Client) (Totals, error)

CountTotals counts accounts that are not deleted, players and public textures.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL