Describe query

This commit is contained in:
x032205
2025-07-14 18:01:35 -04:00
parent 513f942aae
commit 2f0a247c11
@@ -54,10 +54,22 @@ export const identityAccessTokenDALFactory = (db: TDbClient) => {
); );
}) })
.orWhere((qb) => { .orWhere((qb) => {
void qb void qb.where("accessTokenTTL", ">", 0).andWhereRaw(
.where("accessTokenTTL", ">", 0) `
.andWhereRaw( -- Check if the token's effective expiration time has passed.
`COALESCE("${TableName.IdentityAccessToken}"."accessTokenLastRenewedAt", "${TableName.IdentityAccessToken}"."createdAt") + make_interval(secs => LEAST("${TableName.IdentityAccessToken}"."accessTokenTTL", ?)) < NOW()`, -- The expiration time is calculated by adding its TTL to its last renewal/creation time.
COALESCE(
"${TableName.IdentityAccessToken}"."accessTokenLastRenewedAt", -- Use last renewal time if available
"${TableName.IdentityAccessToken}"."createdAt" -- Otherwise, use creation time
)
+ make_interval(
secs => LEAST(
"${TableName.IdentityAccessToken}"."accessTokenTTL", -- Token's specified TTL
? -- Capped by MAX_TTL (parameterized value)
)
)
< NOW() -- Check if the calculated time is before now
`,
[MAX_TTL] [MAX_TTL]
); );
}); });