Skip to content

Commit 4682a74

Browse files
tests
1 parent 73d8829 commit 4682a74

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

modules/module-postgres-storage/src/storage/PostgresReportStorageFactory.ts

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,25 @@ export class PostgresReportStorageFactory implements storage.ReportStorageFactor
195195
disconnect_at = NULL
196196
WHERE sdk_report_events.connect_at >= $8
197197
AND sdk_report_events.connect_at < $9;`;
198-
const params = [
199-
{ value: user_id },
200-
{ value: client_id },
201-
{ value: connect_at },
202-
{ value: sdk },
203-
{ value: user_agent },
204-
{ value: jwt_exp },
205-
{ value: v4() },
206-
{ value: gte },
207-
{ value: lt }
208-
];
209-
await this.db.query({ statement: query, params });
198+
try {
199+
const result = await this.db.query({
200+
statement: query,
201+
params: [
202+
{ type: 'varchar', value: user_id },
203+
{ type: 'varchar', value: client_id },
204+
{ type: 'varchar', value: connect_at },
205+
{ type: 'varchar', value: sdk },
206+
{ type: 'varchar', value: user_agent },
207+
{ type: 1184, value: jwt_exp?.toISOString() },
208+
{ type: 'varchar', value: v4() },
209+
{ type: 1184, value: gte },
210+
{ type: 1184, value: lt }
211+
]
212+
});
213+
console.log(result.rows);
214+
} catch (error) {
215+
console.log(error);
216+
}
210217
}
211218
async reportSdkDisconnect(data: SdkDisconnectEventData): Promise<void> {
212219
const { user_id, client_id, disconnect_at } = data;
@@ -220,8 +227,22 @@ export class PostgresReportStorageFactory implements storage.ReportStorageFactor
220227
AND client_id = $3
221228
AND connect_at >= $4
222229
AND connect_at < $5;`;
223-
const params = [{ value: disconnect_at }, { value: user_id }, { value: client_id }, { value: gte }, { value: lt }];
224-
await this.db.query({ statement: query, params });
230+
231+
try {
232+
const result = await this.db.query({
233+
statement: query,
234+
params: [
235+
{ type: 1184, value: disconnect_at },
236+
{ type: 'varchar', value: user_id },
237+
{ type: 'varchar', value: client_id },
238+
{ type: 1184, value: gte },
239+
{ type: 1184, value: lt }
240+
]
241+
});
242+
console.log(result.rows);
243+
} catch (error) {
244+
console.log(error);
245+
}
225246
}
226247
async listCurrentConnections(data: ListCurrentConnectionsRequest): Promise<ListCurrentConnections> {
227248
const statement = this.listConnectionsDateRangeQuery(data);

0 commit comments

Comments
 (0)