MCPcopy
hub / github.com/Unleash/unleash / queryCount

Method queryCount

src/lib/features/events/event-store.ts:430–460  ·  view source on GitHub ↗
(operations: IQueryOperations[])

Source from the content-addressed store, hash-verified

428 }
429
430 async queryCount(operations: IQueryOperations[]): Promise<number> {
431 const stopTimer = this.metricTimer('queryCount');
432 try {
433 let query: Knex.QueryBuilder = this.db.count().from(TABLE);
434
435 operations.forEach((operation) => {
436 if (operation.op === 'where') {
437 query = this.where(query, operation.parameters);
438 }
439
440 if (operation.op === 'forFeatures') {
441 query = this.forFeatures(query, operation.parameters);
442 }
443
444 if (operation.op === 'beforeDate') {
445 query = this.beforeDate(query, operation.parameters);
446 }
447
448 if (operation.op === 'betweenDate') {
449 query = this.betweenDate(query, operation.parameters);
450 }
451 });
452
453 const queryResult = await query.first();
454 return Number.parseInt(queryResult.count || 0, 10);
455 } catch (_e) {
456 return 0;
457 } finally {
458 stopTimer();
459 }
460 }
461
462 where(
463 query: Knex.QueryBuilder,

Callers

nothing calls this directly

Calls 5

whereMethod · 0.95
forFeaturesMethod · 0.95
beforeDateMethod · 0.95
betweenDateMethod · 0.95
countMethod · 0.65

Tested by

no test coverage detected