({
projectId,
profileId,
cursor,
filters,
limit = 50,
startDate,
endDate,
}: IEventServiceGetList & {
limit?: number;
startDate?: Date;
endDate?: Date;
})
| 1077 | } |
| 1078 | |
| 1079 | async getList({ |
| 1080 | projectId, |
| 1081 | profileId, |
| 1082 | cursor, |
| 1083 | filters, |
| 1084 | limit = 50, |
| 1085 | startDate, |
| 1086 | endDate, |
| 1087 | }: IEventServiceGetList & { |
| 1088 | limit?: number; |
| 1089 | startDate?: Date; |
| 1090 | endDate?: Date; |
| 1091 | }) { |
| 1092 | const date = cursor || new Date(); |
| 1093 | const query = this.query({ |
| 1094 | projectId, |
| 1095 | profileId, |
| 1096 | limit, |
| 1097 | orderBy: 'created_at', |
| 1098 | filters, |
| 1099 | select: { |
| 1100 | event: { |
| 1101 | deviceId: true, |
| 1102 | profileId: true, |
| 1103 | id: true, |
| 1104 | name: true, |
| 1105 | createdAt: true, |
| 1106 | country: true, |
| 1107 | city: true, |
| 1108 | os: true, |
| 1109 | browser: true, |
| 1110 | path: true, |
| 1111 | sessionId: true, |
| 1112 | }, |
| 1113 | profile: { |
| 1114 | id: true, |
| 1115 | firstName: true, |
| 1116 | lastName: true, |
| 1117 | avatar: true, |
| 1118 | isExternal: true, |
| 1119 | }, |
| 1120 | }, |
| 1121 | where: { |
| 1122 | event: (q) => { |
| 1123 | if (startDate && endDate) { |
| 1124 | q.where('created_at', 'BETWEEN', [ |
| 1125 | startDate ?? new Date(date.getTime() - 1000 * 60 * 60 * 24 * 3.5), |
| 1126 | cursor ?? endDate, |
| 1127 | ]); |
| 1128 | } else { |
| 1129 | q.where('created_at', '<', date); |
| 1130 | } |
| 1131 | if (filters) { |
| 1132 | q.rawWhere( |
| 1133 | Object.values( |
| 1134 | getEventFiltersWhereClause(filters, projectId) |
| 1135 | ).join(' AND ') |
| 1136 | ); |
nothing calls this directly
no test coverage detected