Feature/move list to client (#50)
This commit is contained in:
committed by
GitHub
parent
c2abdaadf2
commit
668434d246
@@ -343,18 +343,18 @@ export async function getEventList({
|
||||
sb.offset = Math.max(0, (cursor ?? 0) * take);
|
||||
sb.where.projectId = `project_id = ${escape(projectId)}`;
|
||||
|
||||
// sb.select.id = 'id';
|
||||
// sb.select.name = 'name';
|
||||
// sb.select.deviceId = 'device_id';
|
||||
// sb.select.profileId = 'profile_id';
|
||||
// sb.select.projectId = 'project_id';
|
||||
// sb.select.createdAt = 'created_at';
|
||||
// sb.select.path = 'path';
|
||||
// sb.select.duration = 'duration';
|
||||
// sb.select.city = 'city';
|
||||
// sb.select.country = 'country';
|
||||
// sb.select.os = 'os';
|
||||
// sb.select.browser = 'browser';
|
||||
sb.select.id = 'id';
|
||||
sb.select.name = 'name';
|
||||
sb.select.deviceId = 'device_id';
|
||||
sb.select.profileId = 'profile_id';
|
||||
sb.select.projectId = 'project_id';
|
||||
sb.select.createdAt = 'created_at';
|
||||
sb.select.path = 'path';
|
||||
sb.select.duration = 'duration';
|
||||
sb.select.city = 'city';
|
||||
sb.select.country = 'country';
|
||||
sb.select.os = 'os';
|
||||
sb.select.browser = 'browser';
|
||||
|
||||
if (profileId) {
|
||||
sb.where.deviceId = `device_id IN (SELECT device_id as did FROM ${TABLE_NAMES.events} WHERE profile_id = ${escape(profileId)} group by did)`;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { uniq } from 'ramda';
|
||||
import { omit, uniq } from 'ramda';
|
||||
import { escape } from 'sqlstring';
|
||||
|
||||
import { toObject } from '@openpanel/common';
|
||||
@@ -59,6 +59,8 @@ export async function getProfileById(id: string, projectId: string) {
|
||||
return transformProfile(profile);
|
||||
}
|
||||
|
||||
export const getProfileByIdCached = cacheable(getProfileById, 60 * 30);
|
||||
|
||||
interface GetProfileListOptions {
|
||||
projectId: string;
|
||||
take: number;
|
||||
@@ -122,6 +124,7 @@ export type IServiceProfile = Omit<
|
||||
createdAt: Date;
|
||||
isExternal: boolean;
|
||||
properties: Record<string, unknown> & {
|
||||
region?: string;
|
||||
country?: string;
|
||||
city?: string;
|
||||
os?: string;
|
||||
@@ -130,6 +133,10 @@ export type IServiceProfile = Omit<
|
||||
browser_version?: string;
|
||||
referrer_name?: string;
|
||||
referrer_type?: string;
|
||||
device?: string;
|
||||
brand?: string;
|
||||
model?: string;
|
||||
referrer?: string;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -167,7 +174,10 @@ export function transformProfile({
|
||||
firstName: first_name,
|
||||
lastName: last_name,
|
||||
isExternal: profile.is_external,
|
||||
properties: toObject(profile.properties),
|
||||
properties: omit(
|
||||
['browserVersion', 'osVersion'],
|
||||
toObject(profile.properties)
|
||||
),
|
||||
createdAt: new Date(created_at),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user