mirror of
https://github.com/idanoo/go-mastodon-stats
synced 2025-07-01 22:02:20 +00:00
Rolling 1 week stats
This commit is contained in:
parent
17b1f261a0
commit
88ee8ac2a7
2 changed files with 22 additions and 4 deletions
|
@ -22,7 +22,8 @@ var (
|
||||||
MASTODON_CLIENT_PASSWORD string
|
MASTODON_CLIENT_PASSWORD string
|
||||||
|
|
||||||
// UserCount metric name
|
// UserCount metric name
|
||||||
METRICNAME_USERCOUNT = "userCount"
|
METRICNAME_USERCOUNT = "userCount"
|
||||||
|
METRICNAME_1W_USERCOUNT = "userCount1W"
|
||||||
|
|
||||||
// This is hardcoded because.. well configs are annoying
|
// This is hardcoded because.. well configs are annoying
|
||||||
SERVICE_LINKS = map[string]string{
|
SERVICE_LINKS = map[string]string{
|
||||||
|
@ -44,9 +45,10 @@ var (
|
||||||
MATRIX_IDENTIFIDER = "matrix"
|
MATRIX_IDENTIFIDER = "matrix"
|
||||||
|
|
||||||
// Mastodon
|
// Mastodon
|
||||||
MASTODON_DB_SCHEMA string
|
MASTODON_DB_SCHEMA string
|
||||||
MASTODON_USER_QUERY = "SELECT count(*) FROM users WHERE disabled = False AND confirmed_at IS NOT NULL AND approved = True;"
|
MASTODON_USER_QUERY = "SELECT count(*) FROM users WHERE disabled = False AND confirmed_at IS NOT NULL AND approved = True;"
|
||||||
MASTODON_IDENTIFIER = "mastodon"
|
MASTODON_1W_ACTIVE_USER_QUERY = "SELECT count(*) FROM users WHERE disabled = False AND confirmed_at IS NOT NULL AND approved = True AND current_sign_in_at >= now() - interval '1 week';"
|
||||||
|
MASTODON_IDENTIFIER = "mastodon"
|
||||||
|
|
||||||
// Mobilizon
|
// Mobilizon
|
||||||
MOBILIZON_DB_SCHEMA string
|
MOBILIZON_DB_SCHEMA string
|
||||||
|
|
|
@ -86,6 +86,22 @@ func getUserCounts() ([]metric, error) {
|
||||||
log.Printf("%s user count: %d", MASTODON_IDENTIFIER, userCount)
|
log.Printf("%s user count: %d", MASTODON_IDENTIFIER, userCount)
|
||||||
metrics = append(metrics, m)
|
metrics = append(metrics, m)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extra metrics for DB only
|
||||||
|
userCount1W, err := runIntQuery(MASTODON_DB_SCHEMA, MASTODON_1W_ACTIVE_USER_QUERY)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
} else {
|
||||||
|
customMetrics := []metric{
|
||||||
|
{
|
||||||
|
Service: MATRIX_IDENTIFIDER,
|
||||||
|
MetricName: METRICNAME_1W_USERCOUNT,
|
||||||
|
MetricValue: userCount1W,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = persistMetrics(customMetrics)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if MOBILIZON_DB_SCHEMA != "" {
|
if MOBILIZON_DB_SCHEMA != "" {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue