MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / querySessionsCore

Function querySessionsCore

packages/db/src/services/session.service.ts:480–549  ·  view source on GitHub ↗
(
  input: QuerySessionsInput
)

Source from the content-addressed store, hash-verified

478}
479
480export async function querySessionsCore(
481 input: QuerySessionsInput
482): Promise<IClickhouseSession[]> {
483 const builder = clix(ch)
484 .select<IClickhouseSession>([])
485 .from(TABLE_NAMES.sessions)
486 .where('project_id', '=', input.projectId)
487 .where('sign', '=', 1);
488
489 if (input.profileId) {
490 builder.where('profile_id', '=', input.profileId);
491 }
492
493 if (input.referrer) {
494 builder.where('referrer', '=', input.referrer);
495 }
496
497 if (input.referrerName) {
498 builder.where('referrer_name', '=', input.referrerName);
499 }
500
501 if (input.referrerType) {
502 builder.where('referrer_type', '=', input.referrerType);
503 }
504
505 if (input.device) {
506 builder.where('device', '=', input.device);
507 }
508
509 if (input.country) {
510 builder.where('country', '=', input.country);
511 }
512
513 if (input.city) {
514 builder.where('city', '=', input.city);
515 }
516
517 if (input.os) {
518 builder.where('os', '=', input.os);
519 }
520
521 if (input.browser) {
522 builder.where('browser', '=', input.browser);
523 }
524
525 const { startDate: start, endDate: end } = resolveDateRange(
526 input.startDate,
527 input.endDate
528 );
529
530 builder.where('created_at', 'BETWEEN', [
531 clix.datetime(start),
532 clix.datetime(end),
533 ]);
534
535 if (input.filters?.length) {
536 const filterClauses = buildFilterWhere(input.filters, input.projectId, {
537 selfTable: 'sessions',

Callers 4

registerSessionToolsFunction · 0.90
querySessionsFunction · 0.90
base.tsFile · 0.90
session.tsFile · 0.90

Calls 9

clixFunction · 0.90
resolveDateRangeFunction · 0.90
buildFilterWhereFunction · 0.90
selectMethod · 0.80
executeMethod · 0.80
limitMethod · 0.80
whereMethod · 0.45
fromMethod · 0.45
rawWhereMethod · 0.45

Tested by

no test coverage detected