feat(filters): show current download count in list (#2001)

* feat(filters): show current and max downloads in list

* feat(filters): remove unused func param
This commit is contained in:
ze0s 2025-03-16 18:33:47 +01:00 committed by GitHub
parent c85fa3f31a
commit ef7317dde6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 63 additions and 9 deletions

View file

@ -62,6 +62,8 @@ func (r *FilterRepo) find(ctx context.Context, params domain.FilterQueryParams)
"f.enabled",
"f.name",
"f.priority",
"f.max_downloads",
"f.max_downloads_unit",
"f.created_at",
"f.updated_at",
).
@ -108,10 +110,21 @@ func (r *FilterRepo) find(ctx context.Context, params domain.FilterQueryParams)
for rows.Next() {
var f domain.Filter
if err := rows.Scan(&f.ID, &f.Enabled, &f.Name, &f.Priority, &f.CreatedAt, &f.UpdatedAt, &f.ActionsCount, &f.ActionsEnabledCount, &f.IsAutoUpdated); err != nil {
var maxDownloadsUnit sql.Null[string]
var maxDownloads sql.Null[int32]
if err := rows.Scan(&f.ID, &f.Enabled, &f.Name, &f.Priority, &maxDownloads, &maxDownloadsUnit, &f.CreatedAt, &f.UpdatedAt, &f.ActionsCount, &f.ActionsEnabledCount, &f.IsAutoUpdated); err != nil {
return nil, errors.Wrap(err, "error scanning row")
}
if maxDownloads.Valid {
f.MaxDownloads = int(maxDownloads.V)
}
if maxDownloadsUnit.Valid {
f.MaxDownloadsUnit = domain.FilterMaxDownloadsUnit(maxDownloadsUnit.V)
}
filters = append(filters, f)
}
if err := rows.Err(); err != nil {