*actually* cache counts

This commit is contained in:
Sam 2023-06-25 15:55:44 +02:00
parent 80cf699a73
commit 969e06e31e
Signed by: sam
GPG key ID: B4EF20DDE721CAA1

View file

@ -134,7 +134,7 @@ func (db *DB) initMetrics() (err error) {
func (db *DB) Counts(ctx context.Context) (numUsers, numMembers, usersDay, usersWeek, usersMonth int64) {
db.countMu.Lock()
if numUsers != 0 {
if db.usersTotal != 0 {
defer db.countMu.Unlock()
return db.usersTotal, db.membersTotal, db.activeUsersDay, db.activeUsersWeek, db.activeUsersMonth
}