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 ¶
const Days = 31
Days is how many days the overview chart covers, today included (as Blessing Skin).
Variables ¶
This section is empty.
Functions ¶
Types ¶
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.