From fb12d735ff00ad74862181ee0a26a129d6d0029c Mon Sep 17 00:00:00 2001 From: Alexey Zinoviev Date: Wed, 16 Apr 2025 17:52:42 +0400 Subject: [PATCH] uberf-10227: fix createdOn type in getUserWorkspaces (#8584) Signed-off-by: Alexey Zinoviev --- server/account/src/__tests__/postgres.test.ts | 9 +++++++-- server/account/src/collections/postgres.ts | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/server/account/src/__tests__/postgres.test.ts b/server/account/src/__tests__/postgres.test.ts index ad8d315216..383d19298e 100644 --- a/server/account/src/__tests__/postgres.test.ts +++ b/server/account/src/__tests__/postgres.test.ts @@ -573,12 +573,14 @@ describe('PostgresAccountDB', () => { uuid: workspaceId, name: 'Test', url: 'test', + created_on: '1234567890000', status: { mode: 'active', version_major: 1, version_minor: 0, version_patch: 0, - is_disabled: false + is_disabled: false, + last_processing_time: '1234567890000' } } ] @@ -591,12 +593,15 @@ describe('PostgresAccountDB', () => { uuid: workspaceId, name: 'Test', url: 'test', + createdOn: 1234567890000, status: { mode: 'active', versionMajor: 1, versionMinor: 0, versionPatch: 0, - isDisabled: false + isDisabled: false, + lastProcessingTime: 1234567890000, + lastVisit: null } }) }) diff --git a/server/account/src/collections/postgres.ts b/server/account/src/collections/postgres.ts index 68371d370a..b2c07d1f33 100644 --- a/server/account/src/collections/postgres.ts +++ b/server/account/src/collections/postgres.ts @@ -92,6 +92,12 @@ function formatVar (idx: number, type?: string): string { return type != null ? `$${idx}::${type}` : `$${idx}` } +function convertTimestamp (ts: string): number | null { + const val = Number.parseInt(ts) + + return Number.isNaN(val) ? null : val +} + export interface PostgresDbCollectionOptions, K extends keyof T | undefined = undefined> { idKey?: K ns?: string @@ -229,8 +235,7 @@ implements DbCollection { protected convertToObj (row: unknown): T { const res = convertKeysToCamelCase(row) for (const field of this.timestampFields) { - const val = Number.parseInt(res[field]) - res[field] = Number.isNaN(val) ? null : val + res[field] = convertTimestamp(res[field]) } return res as T @@ -589,6 +594,12 @@ export class PostgresAccountDB implements AccountDB { const res: any = await this.client.unsafe(sql, [accountUuid]) + for (const row of res) { + row.created_on = convertTimestamp(row.created_on) + row.status.last_processing_time = convertTimestamp(row.status.last_processing_time) + row.status.last_visit = convertTimestamp(row.status.last_visit) + } + return convertKeysToCamelCase(res) }