Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: radars #283

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions packages/backend/src/jobs/radar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ async function runRadarChecksOnRun(radar: any, run: any) {
async function getRadarRuns(radar: any) {
const filtersQuery = convertChecksToSQL(radar.view)

const excludedRunsSubquery = sql`select run_id from radar_result where radar_id = ${radar.id}`

// get more recent runs first
return await sql`
select * from run
select
*
from
run
left join radar_result on run.id = radar_result.run_id
and radar_result.radar_id = ${radar.id}
where
project_id = ${radar.projectId}
and (${filtersQuery})
and id not in (${excludedRunsSubquery})
order by created_at desc
and radar_result.run_id is null
order by
run.created_at desc
limit ${RUNS_BATCH_SIZE}
`
}
Expand Down Expand Up @@ -77,6 +81,7 @@ async function radarJob() {

if (!runs.length) {
console.log(`Skipping radar ${radar.id} (${i} / ${radars.length})`)
await sleep(1000)
continue
}

Expand Down
Loading