diff --git a/pkg/datastore/datastore.go b/pkg/datastore/datastore.go index 82eda8f..241e236 100644 --- a/pkg/datastore/datastore.go +++ b/pkg/datastore/datastore.go @@ -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 { diff --git a/pkg/datastore/gormstore/operations.go b/pkg/datastore/gormstore/operations.go index bf49c86..87b456f 100644 --- a/pkg/datastore/gormstore/operations.go +++ b/pkg/datastore/gormstore/operations.go @@ -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 +}