From 6d1003dcbd71f9b0bc6fa6bcbb6770951969be7b Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Thu, 12 Mar 2026 00:30:19 +0000 Subject: [PATCH] Show the actual total number of tasks pending --- api/review_task.go | 27 ++++++++++++++++++++++----- html/template/sync/review/pool.html | 2 +- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/api/review_task.go b/api/review_task.go index fb902f09..94fc772e 100644 --- a/api/review_task.go +++ b/api/review_task.go @@ -29,9 +29,29 @@ type reviewTaskPool struct { } type contentListReviewTaskPool struct { Tasks []reviewTaskPool `json:"tasks"` + Total int32 `json:"total"` } func listReviewTaskPool(ctx context.Context, r *http.Request, org *models.Organization, user *models.User, query queryParams) (*contentListReviewTaskPool, *nhttp.ErrorWithStatus) { + limit := 20 + if query.Limit != nil { + limit = *query.Limit + } + type _RowTotal struct { + Total int32 `db:"total"` + } + row_total, err := bob.One(ctx, db.PGInstance.BobDB, psql.Select( + sm.Columns( + "COUNT(*) AS total", + ), + sm.From("review_task"), + sm.Where(psql.Quote("review_task", "organization_id").EQ(psql.Arg(org.ID))), + sm.Where(psql.Quote("review_task", "reviewed").IsNull()), + ), scan.StructMapper[_RowTotal]()) + if err != nil { + return nil, nhttp.NewError("failed to total count: %w", err) + } + type _Row struct { Address types.Address `db:"address"` Condition string `db:"condition"` @@ -46,10 +66,6 @@ func listReviewTaskPool(ctx context.Context, r *http.Request, org *models.Organi Title string `db:"title"` Type string `db:"type"` } - limit := 20 - if query.Limit != nil { - limit = *query.Limit - } rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select( sm.Columns( "feature_pool.condition AS condition", @@ -96,7 +112,7 @@ func listReviewTaskPool(ctx context.Context, r *http.Request, org *models.Organi sm.Limit(limit), ), scan.StructMapper[_Row]()) if err != nil { - return nil, nhttp.NewError("failed to get signals: %w", err) + return nil, nhttp.NewError("failed to get review tasks: %w", err) } users_by_id, err := platform.UsersByID(ctx, org) if err != nil { @@ -120,5 +136,6 @@ func listReviewTaskPool(ctx context.Context, r *http.Request, org *models.Organi } return &contentListReviewTaskPool{ Tasks: tasks, + Total: row_total.Total, }, nil } diff --git a/html/template/sync/review/pool.html b/html/template/sync/review/pool.html index f1906a56..48a1aacd 100644 --- a/html/template/sync/review/pool.html +++ b/html/template/sync/review/pool.html @@ -106,7 +106,7 @@ const data = await response.json(); this.tasks = data.tasks || []; - this.totalPending = data.totalPending || this.tasks.length; + this.totalPending = data.total || this.tasks.length; // Auto-select first task if available if (this.tasks.length > 0 && !this.selectedTask) {