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

Function getProfileWithEvents

packages/db/src/services/profile.service.ts:473–499  ·  view source on GitHub ↗
(
  projectId: string,
  profileId: string,
  eventLimit = 10
)

Source from the content-addressed store, hash-verified

471}
472
473export async function getProfileWithEvents(
474 projectId: string,
475 profileId: string,
476 eventLimit = 10
477): Promise<{
478 profile: IClickhouseProfile | null;
479 recent_events: IClickhouseEvent[];
480}> {
481 const [profiles, recent_events] = await Promise.all([
482 chQuery<IClickhouseProfile>(`
483 SELECT ${PROFILE_COLUMNS}
484 FROM ${TABLE_NAMES.profiles} FINAL
485 WHERE project_id = ${sqlstring.escape(projectId)} AND id = ${sqlstring.escape(profileId)}
486 LIMIT 1
487 `),
488 clix(ch)
489 .select<IClickhouseEvent>([])
490 .from(TABLE_NAMES.events)
491 .where('project_id', '=', projectId)
492 .where('profile_id', '=', profileId)
493 .orderBy('created_at', 'DESC')
494 .limit(eventLimit)
495 .execute(),
496 ]);
497
498 return { profile: profiles[0] ?? null, recent_events };
499}
500
501export function getProfileSessionsCore(
502 projectId: string,

Callers 3

registerProfileToolsFunction · 0.90
getProfileFunction · 0.90
profile.tsFile · 0.90

Calls 8

chQueryFunction · 0.90
clixFunction · 0.90
executeMethod · 0.80
limitMethod · 0.80
orderByMethod · 0.80
selectMethod · 0.80
whereMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected