activity: add counter for total, loaded and shown

total: number of activities in the DB
loaded: How many the web UI has loaded
shown: How many are shown (differs when in a search).
This commit is contained in:
Harvey Tindall
2023-10-23 11:34:04 +01:00
parent 591b843148
commit 663389693f
6 changed files with 76 additions and 3 deletions
+16
View File
@@ -168,3 +168,19 @@ func (app *appContext) DeleteActivity(gc *gin.Context) {
app.storage.DeleteActivityKey(gc.Param("id"))
respondBool(200, true, gc)
}
// @Summary Returns the total number of activities stored in the database.
// @Produce json
// @Success 200 {object} GetActivityCountDTO
// @Router /activity/count [get]
// @Security Bearer
// @tags Activity
func (app *appContext) GetActivityCount(gc *gin.Context) {
resp := GetActivityCountDTO{}
var err error
resp.Count, err = app.storage.db.Count(&Activity{}, &badgerhold.Query{})
if err != nil {
resp.Count = 0
}
gc.JSON(200, resp)
}