Revert "improve(funnel): make sure group by profile id works as you would think"
This reverts commit 56edb91dd0.
This commit is contained in:
@@ -245,30 +245,30 @@ export async function getEvents(
|
||||
): Promise<IServiceEvent[]> {
|
||||
const events = await chQuery<IClickhouseEvent>(sql);
|
||||
const projectId = events[0]?.project_id;
|
||||
const [meta, profiles] = await Promise.all([
|
||||
options.meta && projectId
|
||||
? db.eventMeta.findMany({
|
||||
where: {
|
||||
name: {
|
||||
in: uniq(events.map((e) => e.name)),
|
||||
},
|
||||
},
|
||||
})
|
||||
: null,
|
||||
options.profile && projectId
|
||||
? getProfiles(uniq(events.map((e) => e.profile_id)), projectId)
|
||||
: null,
|
||||
]);
|
||||
if (options.profile && projectId) {
|
||||
const ids = events.map((e) => e.profile_id);
|
||||
const profiles = await getProfiles(ids, projectId);
|
||||
|
||||
for (const event of events) {
|
||||
if (profiles) {
|
||||
for (const event of events) {
|
||||
event.profile = profiles.find((p) => p.id === event.profile_id);
|
||||
}
|
||||
if (meta) {
|
||||
event.meta = meta.find((m) => m.name === event.name);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.meta && projectId) {
|
||||
const names = uniq(events.map((e) => e.name));
|
||||
const metas = await db.eventMeta.findMany({
|
||||
where: {
|
||||
name: {
|
||||
in: names,
|
||||
},
|
||||
projectId,
|
||||
},
|
||||
select: options.meta === true ? undefined : options.meta,
|
||||
});
|
||||
for (const event of events) {
|
||||
event.meta = metas.find((m) => m.name === event.name);
|
||||
}
|
||||
}
|
||||
return events.map(transformEvent);
|
||||
}
|
||||
|
||||
@@ -477,7 +477,7 @@ export async function getEventList({
|
||||
}
|
||||
|
||||
if (profileId) {
|
||||
sb.where.deviceId = `(device_id IN (SELECT device_id as did FROM ${TABLE_NAMES.events} WHERE project_id = ${escape(projectId)} AND device_id != '' AND profile_id = ${escape(profileId)} group by did) OR profile_id = ${escape(profileId)})`;
|
||||
sb.where.deviceId = `(device_id IN (SELECT device_id as did FROM ${TABLE_NAMES.events} WHERE device_id != '' AND profile_id = ${escape(profileId)} group by did) OR profile_id = ${escape(profileId)})`;
|
||||
}
|
||||
|
||||
if (startDate && endDate) {
|
||||
|
||||
Reference in New Issue
Block a user