Show the actual total number of tasks pending
This commit is contained in:
parent
40e7c8fdbe
commit
6d1003dcbd
2 changed files with 23 additions and 6 deletions
|
|
@ -29,9 +29,29 @@ type reviewTaskPool struct {
|
||||||
}
|
}
|
||||||
type contentListReviewTaskPool struct {
|
type contentListReviewTaskPool struct {
|
||||||
Tasks []reviewTaskPool `json:"tasks"`
|
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) {
|
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 {
|
type _Row struct {
|
||||||
Address types.Address `db:"address"`
|
Address types.Address `db:"address"`
|
||||||
Condition string `db:"condition"`
|
Condition string `db:"condition"`
|
||||||
|
|
@ -46,10 +66,6 @@ func listReviewTaskPool(ctx context.Context, r *http.Request, org *models.Organi
|
||||||
Title string `db:"title"`
|
Title string `db:"title"`
|
||||||
Type string `db:"type"`
|
Type string `db:"type"`
|
||||||
}
|
}
|
||||||
limit := 20
|
|
||||||
if query.Limit != nil {
|
|
||||||
limit = *query.Limit
|
|
||||||
}
|
|
||||||
rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
|
rows, err := bob.All(ctx, db.PGInstance.BobDB, psql.Select(
|
||||||
sm.Columns(
|
sm.Columns(
|
||||||
"feature_pool.condition AS condition",
|
"feature_pool.condition AS condition",
|
||||||
|
|
@ -96,7 +112,7 @@ func listReviewTaskPool(ctx context.Context, r *http.Request, org *models.Organi
|
||||||
sm.Limit(limit),
|
sm.Limit(limit),
|
||||||
), scan.StructMapper[_Row]())
|
), scan.StructMapper[_Row]())
|
||||||
if err != nil {
|
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)
|
users_by_id, err := platform.UsersByID(ctx, org)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -120,5 +136,6 @@ func listReviewTaskPool(ctx context.Context, r *http.Request, org *models.Organi
|
||||||
}
|
}
|
||||||
return &contentListReviewTaskPool{
|
return &contentListReviewTaskPool{
|
||||||
Tasks: tasks,
|
Tasks: tasks,
|
||||||
|
Total: row_total.Total,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,7 +106,7 @@
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
this.tasks = data.tasks || [];
|
this.tasks = data.tasks || [];
|
||||||
this.totalPending = data.totalPending || this.tasks.length;
|
this.totalPending = data.total || this.tasks.length;
|
||||||
|
|
||||||
// Auto-select first task if available
|
// Auto-select first task if available
|
||||||
if (this.tasks.length > 0 && !this.selectedTask) {
|
if (this.tasks.length > 0 && !this.selectedTask) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue