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

Method getById

packages/db/src/services/event.service.ts:1030–1077  ·  view source on GitHub ↗
({
    projectId,
    id,
    createdAt,
  }: {
    projectId: string;
    id: string;
    createdAt?: Date;
  })

Source from the content-addressed store, hash-verified

1028 }
1029
1030 async getById({
1031 projectId,
1032 id,
1033 createdAt,
1034 }: {
1035 projectId: string;
1036 id: string;
1037 createdAt?: Date;
1038 }) {
1039 const [event, metas] = await Promise.all([
1040 clix(this.client)
1041 .select<IClickhouseEvent>(['*'])
1042 .from('events')
1043 .where('project_id', '=', projectId)
1044 .when(!!createdAt, (q) => {
1045 if (createdAt) {
1046 q.where('created_at', 'BETWEEN', [
1047 new Date(createdAt.getTime() - 1000),
1048 new Date(createdAt.getTime() + 1000),
1049 ]);
1050 }
1051 })
1052 .where('id', '=', id)
1053 .limit(1)
1054 .execute()
1055 .then((res) => {
1056 if (!res[0]) {
1057 return null;
1058 }
1059
1060 return transformEvent(res[0]);
1061 }),
1062 getEventMetasCached(projectId),
1063 ]);
1064
1065 if (event?.profileId) {
1066 const profile = await getProfileById(event?.profileId, projectId);
1067 if (profile) {
1068 event.profile = profile;
1069 }
1070 }
1071
1072 if (event) {
1073 event.meta = metas.find((meta) => meta.name === event.name);
1074 }
1075
1076 return event;
1077 }
1078
1079 async getList({
1080 projectId,

Callers 1

event.tsFile · 0.80

Calls 10

clixFunction · 0.90
getProfileByIdFunction · 0.90
transformEventFunction · 0.85
executeMethod · 0.80
limitMethod · 0.80
whenMethod · 0.80
selectMethod · 0.80
thenMethod · 0.45
whereMethod · 0.45
fromMethod · 0.45

Tested by

no test coverage detected