Add Scene 7 claim report workflow
This commit is contained in:
+22
-3
@@ -10,6 +10,8 @@ function mapped(ids: IdMap, sourceId: string, label: string) {
|
||||
}
|
||||
|
||||
export async function clearBoard(client: PoolClient, boardId: string) {
|
||||
await client.query('DELETE FROM osint.case_report_submissions WHERE board_id=$1', [boardId])
|
||||
await client.query('DELETE FROM osint.case_reports WHERE board_id=$1', [boardId])
|
||||
await client.query('DELETE FROM osint.board_views WHERE board_id=$1', [boardId])
|
||||
await client.query('DELETE FROM osint.brief_concepts WHERE board_id=$1', [boardId])
|
||||
await client.query('DELETE FROM osint.level_briefs WHERE board_id=$1', [boardId])
|
||||
@@ -64,11 +66,17 @@ export async function cloneBoard(client: PoolClient, sourceBoardId: string, targ
|
||||
|
||||
const documents = await client.query<{
|
||||
exhibit_id: string; document_type_id: string; asset_id: string | null; title: string
|
||||
published_at: Date | null; captured_at: Date | null; source_uri: string | null
|
||||
published_at: Date | null; captured_at: Date | null; source_uri: string | null; citation_text:string
|
||||
}>(`SELECT d.* FROM osint.document_exhibits d JOIN osint.exhibits e ON e.id=d.exhibit_id WHERE e.board_id=$1`, [sourceBoardId])
|
||||
for (const row of documents.rows) await client.query(`INSERT INTO osint.document_exhibits
|
||||
(exhibit_id,document_type_id,asset_id,title,published_at,captured_at,source_uri) VALUES ($1,$2,$3,$4,$5,$6,$7)`,
|
||||
[mapped(exhibitIds, row.exhibit_id, 'document'), row.document_type_id, row.asset_id, row.title, row.published_at, row.captured_at, row.source_uri])
|
||||
(exhibit_id,document_type_id,asset_id,title,published_at,captured_at,source_uri,citation_text) VALUES ($1,$2,$3,$4,$5,$6,$7,$8)`,
|
||||
[mapped(exhibitIds, row.exhibit_id, 'document'), row.document_type_id, row.asset_id, row.title, row.published_at, row.captured_at, row.source_uri,row.citation_text])
|
||||
|
||||
const citations = await client.query<{ exhibit_id:string;display_number:number }>(
|
||||
'SELECT exhibit_id,display_number FROM osint.exhibit_citations WHERE board_id=$1 ORDER BY display_number',[sourceBoardId])
|
||||
for (const row of citations.rows) await client.query(
|
||||
'INSERT INTO osint.exhibit_citations (board_id,exhibit_id,display_number) VALUES ($1,$2,$3)',
|
||||
[targetBoardId,mapped(exhibitIds,row.exhibit_id,'cited exhibit'),row.display_number])
|
||||
|
||||
const documentRequirements = await client.query<{ document_exhibit_id: string; flag_key: string }>(
|
||||
'SELECT document_exhibit_id,flag_key FROM osint.document_flag_requirements WHERE board_id=$1 ORDER BY document_exhibit_id,flag_key', [sourceBoardId])
|
||||
@@ -137,6 +145,12 @@ export async function cloneBoard(client: PoolClient, sourceBoardId: string, targ
|
||||
for (const row of notes.rows) await client.query('INSERT INTO osint.note_exhibits (exhibit_id,title,note_text) VALUES ($1,$2,$3)',
|
||||
[mapped(exhibitIds, row.exhibit_id, 'note'), row.title, row.note_text])
|
||||
|
||||
const claims = await client.query<{ exhibit_id:string;statement:string }>(
|
||||
`SELECT claim.exhibit_id,claim.statement FROM osint.claim_exhibits claim
|
||||
JOIN osint.exhibits exhibit ON exhibit.id=claim.exhibit_id WHERE exhibit.board_id=$1`,[sourceBoardId])
|
||||
for (const row of claims.rows) await client.query('INSERT INTO osint.claim_exhibits (exhibit_id,statement) VALUES ($1,$2)',
|
||||
[mapped(exhibitIds,row.exhibit_id,'claim'),row.statement])
|
||||
|
||||
const events = await client.query<{ exhibit_id: string; title: string; narrative_text: string; occurred_at: Date | null }>(
|
||||
`SELECT ev.* FROM osint.event_exhibits ev JOIN osint.exhibits e ON e.id=ev.exhibit_id WHERE e.board_id=$1`, [sourceBoardId])
|
||||
for (const row of events.rows) await client.query(
|
||||
@@ -246,5 +260,10 @@ export async function cloneBoard(client: PoolClient, sourceBoardId: string, targ
|
||||
[randomUUID(), targetBoardId, row.id, row.label, row.context_text, row.sort_order, row.expected_party_kind,
|
||||
row.resolved_party_exhibit_id ? mapped(exhibitIds, row.resolved_party_exhibit_id, 'resolved party') : null])
|
||||
|
||||
const report = (await client.query<{ title:string;required_for_completion:boolean }>(
|
||||
'SELECT title,required_for_completion FROM osint.case_reports WHERE board_id=$1',[sourceBoardId])).rows[0]
|
||||
if (report) await client.query(`INSERT INTO osint.case_reports (board_id,title,investigator_name,required_for_completion)
|
||||
VALUES ($1,$2,'',$3)`,[targetBoardId,report.title,report.required_for_completion])
|
||||
|
||||
return exhibitIds
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user