Files
Joshen Lim 241f7bb721 Chore/shift manual queries into pg meta (#43692)
## Context

Related to FE-2557

Part of shifting manually written dashboard queries into
packages/pg-meta where
- pg-meta can be code owners of
- we can write tests for the queries 

This PR just shifts all the `.sql.ts` files that we previously created
into packages/pg-meta

There's still other areas where we need to shift over as well which I'll
address in subsequent PRs

## Notable changes

- `getTableRowsCountSql` -> Opted to shift `formatFilterValue` logic out
before calling this method (ref `table-rows-count-query`)
- `getDeleteOldCronJobRunDetailsByCtidSql` -> Opted to shift
`validatePageNumber` logic out before calling this method (ref
`CronJobsTab.useCleanupActions`)
2026-03-16 16:14:48 +07:00

45 lines
1.7 KiB
TypeScript

import { sqlKeys } from '../sql/keys'
export const databaseCronJobsKeys = {
create: () => ['cron-jobs', 'create'] as const,
delete: () => ['cron-jobs', 'delete'] as const,
alter: () => ['cronjobs', 'alter'] as const,
job: (projectRef: string | undefined, identifier: number | string | undefined) =>
['projects', projectRef, 'cron-jobs', identifier] as const,
listInfinite: (projectRef: string | undefined, searchTerm: string | undefined) =>
['projects', projectRef, 'cron-jobs', { searchTerm }] as const,
listInfiniteMinimal: (projectRef: string | undefined, searchTerm: string | undefined) =>
['projects', projectRef, 'cron-jobs-mininal', { searchTerm }] as const,
count: (projectRef: string | undefined) =>
['projects', projectRef, 'cron-jobs', 'count'] as const,
run: (projectRef: string | undefined, jobId: number) => [
'projects',
projectRef,
'cron-jobs',
jobId,
'run',
],
runsInfinite: (projectRef: string | undefined, jobId: number, options?: object) => [
'projects',
projectRef,
'cron-jobs',
jobId,
options,
],
timezone: (projectRef: string | undefined) => ['database-cron-timezone', projectRef] as const,
}
export const getJobRunDetailsPageCountKey = (projectRef: string | undefined) =>
sqlKeys.query(projectRef, ['cron-job-run-details', 'page-count'])
export const getDeleteOldCronJobRunDetailsByCtidKey = (
projectRef: string | undefined,
interval: string,
startPage: number
) => sqlKeys.query(projectRef, ['cron-job-run-details', 'delete-batch', interval, startPage])
export const getScheduleDeleteCronJobRunDetailsKey = (
projectRef: string | undefined,
interval: string
) => sqlKeys.query(projectRef, ['cron-job-run-details', 'schedule', interval])