submissions: count recent operations
This commit is contained in:
parent
14c7979310
commit
21b6903943
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user