db: use context and go-mockgen for login sources (#7041)

This commit is contained in:
Joe Chen
2022-06-10 19:54:36 +08:00
committed by GitHub
parent 94059f291d
commit 9776bdc9b8
14 changed files with 2175 additions and 407 deletions

View File

@@ -5,6 +5,7 @@
package db
import (
"context"
"database/sql"
"fmt"
"os"
@@ -208,7 +209,7 @@ type Statistic struct {
}
}
func GetStatistic() (stats Statistic) {
func GetStatistic(ctx context.Context) (stats Statistic) {
stats.Counter.User = CountUsers()
stats.Counter.Org = CountOrganizations()
stats.Counter.PublicKey, _ = x.Count(new(PublicKey))
@@ -223,7 +224,7 @@ func GetStatistic() (stats Statistic) {
stats.Counter.Follow, _ = x.Count(new(Follow))
stats.Counter.Mirror, _ = x.Count(new(Mirror))
stats.Counter.Release, _ = x.Count(new(Release))
stats.Counter.LoginSource = LoginSources.Count()
stats.Counter.LoginSource = LoginSources.Count(ctx)
stats.Counter.Webhook, _ = x.Count(new(Webhook))
stats.Counter.Milestone, _ = x.Count(new(Milestone))
stats.Counter.Label, _ = x.Count(new(Label))