( tableId: string, executor: DbOrTx = db )
| 92 | * and SSE consumer derive from these fields. |
| 93 | */ |
| 94 | export async function latestJobForTable( |
| 95 | tableId: string, |
| 96 | executor: DbOrTx = db |
| 97 | ): Promise<DerivedJobFields> { |
| 98 | const [row] = await executor |
| 99 | .select(JOB_PROJECTION) |
| 100 | .from(tableJobs) |
| 101 | .where(and(eq(tableJobs.tableId, tableId), ne(tableJobs.type, 'export'))) |
| 102 | .orderBy(desc(tableJobs.startedAt)) |
| 103 | .limit(1) |
| 104 | return mapJobRow(row) |
| 105 | } |
| 106 | |
| 107 | /** Latest non-export job per table for a batch of ids, via `DISTINCT ON (table_id)`. */ |
| 108 | export async function latestJobsForTables( |
no test coverage detected