submissions: count recent operations

This commit is contained in:
Quaternions 2025-04-04 20:07:09 -07:00
parent 14c7979310
commit 21b6903943
Signed by: Quaternions
GPG Key ID: D0DF5964F79AC131
2 changed files with 10 additions and 0 deletions
pkg/datastore

@ -45,6 +45,7 @@ type Operations interface {
Create(ctx context.Context, smap model.Operation) (model.Operation, error)
Update(ctx context.Context, id int32, values OptionalMap) error
Delete(ctx context.Context, id int32) error
CountSince(ctx context.Context, owner int64, since int64) (int64, error)
}
type Submissions interface {

@ -53,3 +53,12 @@ func (env *Operations) Delete(ctx context.Context, id int32) error {
return nil
}
func (env *Operations) CountSince(ctx context.Context, owner int64, since int64) (int64, error) {
var count int64
if err := env.db.Where("owner = ? AND created_at > ?",owner,since).Count(&count).Error; err != nil {
return count, err
}
return count, nil
}