uberf-10227: fix createdOn type in getUserWorkspaces (#8584)

Signed-off-by: Alexey Zinoviev <alexey.zinoviev@xored.com>
This commit is contained in:
Alexey Zinoviev 2025-04-16 17:52:42 +04:00 committed by GitHub
parent 0c9c985ab8
commit fb12d735ff
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 4 deletions

View File

@ -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
}
})
})

View File

@ -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<T extends Record<string, any>, K extends keyof T | undefined = undefined> {
idKey?: K
ns?: string
@ -229,8 +235,7 @@ implements DbCollection<T> {
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)
}