platformstats

package
v0.51.73 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package platformstats writes daily admin-dashboard rollups to devpulse_platform_stats. Both the admin handler and the import job snapshot stats so DoD/WoW/MoM deltas remain meaningful even on days no admin visits the dashboard.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Snapshot

func Snapshot(ctx context.Context, db *sql.DB) error

Snapshot collects current stats and upserts them under today's UTC date. Safe to call from many places — primary key on date makes it idempotent.

func Upsert

func Upsert(ctx context.Context, db *sql.DB, date string, s Stats) error

Upsert writes stats for date (idempotent — primary key on date).

Types

type Stats

type Stats struct {
	Tenants           int   `json:"tenants"`
	TenantsFree       int   `json:"tenants_free"`
	TenantsStarter    int   `json:"tenants_starter"`
	TenantsPro        int   `json:"tenants_pro"`
	TenantsEnterprise int   `json:"tenants_enterprise"`
	Repos             int   `json:"repos"`
	Events            int64 `json:"events"`
	Contributors      int   `json:"contributors"`
	Installations     int   `json:"installations"`
	ReposWithErrors   int   `json:"repos_with_errors"`
}

Stats is a single daily rollup row in devpulse_platform_stats.

func Collect

func Collect(ctx context.Context, db *sql.DB) (Stats, error)

Collect runs the live aggregate query and returns current stats.

func Get

func Get(ctx context.Context, db *sql.DB, date string) (*Stats, error)

Get returns the stats row for date, or (nil, nil) if no row exists.

Jump to

Keyboard shortcuts

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