0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

chore(core): deprecate unused query methods for logs table (#5464)

This commit is contained in:
Xiao Yijun 2024-03-04 15:50:37 +08:00 committed by GitHub
parent a0a19b13f9
commit 3ae59baf6e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,5 +1,5 @@
import {
token,
type token,
type hook,
Logs,
type HookExecutionStats,
@ -77,33 +77,6 @@ export const createLogQueries = (pool: CommonQueryMethods) => {
const findLogById = buildFindEntityByIdWithPool(pool)(Logs);
const getDailyActiveUserCountsByTimeInterval = async (
startTimeExclusive: number,
endTimeInclusive: number
) =>
pool.any<{ date: string; count: number }>(sql`
select date(${fields.createdAt}), count(distinct(${fields.payload}->>'userId'))
from ${table}
where ${fields.createdAt} > to_timestamp(${startTimeExclusive}::double precision / 1000)
and ${fields.createdAt} <= to_timestamp(${endTimeInclusive}::double precision / 1000)
and ${fields.key} like ${`${token.Type.ExchangeTokenBy}.%`}
and ${fields.payload}->>'result' = 'Success'
group by date(${fields.createdAt})
`);
const countActiveUsersByTimeInterval = async (
startTimeExclusive: number,
endTimeInclusive: number
) =>
pool.one<{ count: number }>(sql`
select count(distinct(${fields.payload}->>'userId'))
from ${table}
where ${fields.createdAt} > to_timestamp(${startTimeExclusive}::double precision / 1000)
and ${fields.createdAt} <= to_timestamp(${endTimeInclusive}::double precision / 1000)
and ${fields.key} like ${`${token.Type.ExchangeTokenBy}.%`}
and ${fields.payload}->>'result' = 'Success'
`);
const getHookExecutionStatsByHookId = async (hookId: string) => {
const startTimeExclusive = subDays(new Date(), 1).getTime();
return pool.one<HookExecutionStats>(sql`
@ -120,8 +93,6 @@ export const createLogQueries = (pool: CommonQueryMethods) => {
countLogs,
findLogs,
findLogById,
getDailyActiveUserCountsByTimeInterval,
countActiveUsersByTimeInterval,
getHookExecutionStatsByHookId,
};
};