mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 12:54:20 +01:00
fix(schedules): resolve older run links and index session lookups
This commit is contained in:
1 parent
0e6e30890a
commit
e497dbfe34
10 files changed
+470
-6
No files matched your search
@@ -0,0 +1,19 @@
|
||||
import type { Migration } from '../migration-runner'
|
||||
|
||||
const migration: Migration = {
|
||||
version: 22,
|
||||
name: 'schedule-runs-session-index',
|
||||
|
||||
up(db) {
|
||||
db.run(`
|
||||
CREATE INDEX IF NOT EXISTS idx_schedule_runs_session
|
||||
ON schedule_runs(session_id, started_at DESC)
|
||||
`)
|
||||
},
|
||||
|
||||
down(db) {
|
||||
db.run('DROP INDEX IF EXISTS idx_schedule_runs_session')
|
||||
},
|
||||
}
|
||||
|
||||
export default migration
|
||||
@@ -20,6 +20,7 @@ import migration018 from './018-session-pins'
|
||||
import migration019 from './019-drop-opencode-configs'
|
||||
import migration020 from './020-drop-opencode-model-state'
|
||||
import migration021 from './021-drop-schedule-run-workspace-id'
|
||||
import migration022 from './022-schedule-runs-session-index'
|
||||
|
||||
export const allMigrations: Migration[] = [
|
||||
migration001,
|
||||
@@ -43,4 +44,5 @@ export const allMigrations: Migration[] = [
|
||||
migration019,
|
||||
migration020,
|
||||
migration021,
|
||||
migration022,
|
||||
]
|
||||
@@ -598,10 +598,11 @@ export interface ListAllRunsOptions {
|
||||
repoId?: number
|
||||
jobId?: number
|
||||
triggerSource?: string
|
||||
runId?: number
|
||||
}
|
||||
|
||||
export function listAllScheduleRuns(db: Database, options: ListAllRunsOptions = {}): ScheduleRunWithContext[] {
|
||||
const { limit = 50, offset = 0, status, repoId, jobId, triggerSource } = options
|
||||
const { limit = 50, offset = 0, status, repoId, jobId, triggerSource, runId } = options
|
||||
const conditions: string[] = []
|
||||
const params: (string | number)[] = []
|
||||
|
||||
@@ -621,6 +622,10 @@ export function listAllScheduleRuns(db: Database, options: ListAllRunsOptions =
|
||||
conditions.push('sr.trigger_source = ?')
|
||||
params.push(triggerSource)
|
||||
}
|
||||
if (runId !== undefined) {
|
||||
conditions.push('sr.id = ?')
|
||||
params.push(runId)
|
||||
}
|
||||
|
||||
const whereClause = conditions.length > 0 ? `WHERE ${conditions.join(' AND ')}` : ''
|
||||
|
||||
|
||||
Reference in new issue
Block a user