mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
chore(core): deprecate unused query methods for logs table (#5464)
This commit is contained in:
parent
a0a19b13f9
commit
3ae59baf6e
1 changed files with 1 additions and 30 deletions
|
@ -1,5 +1,5 @@
|
||||||
import {
|
import {
|
||||||
token,
|
type token,
|
||||||
type hook,
|
type hook,
|
||||||
Logs,
|
Logs,
|
||||||
type HookExecutionStats,
|
type HookExecutionStats,
|
||||||
|
@ -77,33 +77,6 @@ export const createLogQueries = (pool: CommonQueryMethods) => {
|
||||||
|
|
||||||
const findLogById = buildFindEntityByIdWithPool(pool)(Logs);
|
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 getHookExecutionStatsByHookId = async (hookId: string) => {
|
||||||
const startTimeExclusive = subDays(new Date(), 1).getTime();
|
const startTimeExclusive = subDays(new Date(), 1).getTime();
|
||||||
return pool.one<HookExecutionStats>(sql`
|
return pool.one<HookExecutionStats>(sql`
|
||||||
|
@ -120,8 +93,6 @@ export const createLogQueries = (pool: CommonQueryMethods) => {
|
||||||
countLogs,
|
countLogs,
|
||||||
findLogs,
|
findLogs,
|
||||||
findLogById,
|
findLogById,
|
||||||
getDailyActiveUserCountsByTimeInterval,
|
|
||||||
countActiveUsersByTimeInterval,
|
|
||||||
getHookExecutionStatsByHookId,
|
getHookExecutionStatsByHookId,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue