Beginn Personenansicht Beiträge / Anzahl Personenübersicht

This commit is contained in:
Simon Martens
2025-02-28 01:29:16 +01:00
parent ebe2a68d35
commit 9e68532af1
8 changed files with 119 additions and 19 deletions

View File

@@ -290,3 +290,46 @@ func AgentsForOrg(app core.App, org bool, letter string) ([]*Agent, error) {
return agents, nil
}
type AgentCount struct {
Count int `db:"count"`
ID string `db:"id"`
}
func CountAgentsBaende(app core.App) (map[string]int, error) {
couns := []AgentCount{}
err := app.RecordQuery(RelationTableName(ENTRIES_TABLE, AGENTS_TABLE)).
Select("count(*) as count, " + AGENTS_TABLE + " as id").
GroupBy(AGENTS_TABLE).
All(&couns)
if err != nil {
return nil, err
}
ret := make(map[string]int, len(couns))
for _, c := range couns {
ret[c.ID] = c.Count
}
return ret, nil
}
func CountAgentsContents(app core.App) (map[string]int, error) {
couns := []AgentCount{}
err := app.RecordQuery(RelationTableName(CONTENTS_TABLE, AGENTS_TABLE)).
Select("count(*) as count, " + AGENTS_TABLE + " as id").
GroupBy(AGENTS_TABLE).
All(&couns)
if err != nil {
return nil, err
}
ret := make(map[string]int, len(couns))
for _, c := range couns {
ret[c.ID] = c.Count
}
return ret, nil
}