import 'data/gateway.dart'; /// Call sites of the declarative gateway, resolved through adapters.json. class ScheduledJobs { ScheduledJobs(this.gateway); final Gateway gateway; Future reconcile(List statuses) async { await gateway.queryCollectionGroup( 'settlements', inFilter: WhereIn('status', statuses), limit: 200, ); } Future digest(String userId, DateTime from, DateTime to) async { await gateway.queryCollection( 'notifications', filters: [ WhereEquals('userId', userId), const WhereEquals('isRead', false), ], ranges: [WhereRange('createdAt', gte: from, lt: to)], orderBy: const [OrderBy('createdAt', descending: true)], ); } Future followers( String authorId, String? cursor, bool onlyActive) async { final filters = []; if (onlyActive) { filters.add(const WhereEquals('active', true)); } await gateway.queryCollection( 'users', filters: filters, arrayContains: WhereArrayContains('following', authorId), orderBy: const [OrderBy('__name__')], startAfterId: cursor, limit: 500, ); } Future storeScoped(String storeId, int threshold) async { await gateway.queryCollection( 'stores/$storeId/payouts', ranges: [WhereCmp('amount', Cmp.greaterThan, threshold)], ); } Future confirm(String token) async { await gateway.runTransaction((txn) async { return txn.queryCollection( 'confirmations', filters: [WhereEquals('token', token)], limit: 1, ); }); } Future concrete(InMemoryGateway memory, List ids) async { for (final id in ids) { await memory .queryCollection('carts', filters: [WhereEquals('owner', id)]); } } Future notAQuery(String path) async { await gateway.getDocument(path); } }