Skip to content

Commit

Permalink
replace check for receive step with check for report_ids that do not …
Browse files Browse the repository at this point in the history
…appear as child in report_lineage
  • Loading branch information
jack-h-wang committed Dec 5, 2024
1 parent 66c3691 commit 46ec15a
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions prime-router/src/main/kotlin/history/db/ReportGraph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,10 @@ class ReportGraph(
}

/**
* Recursively goes up the report_linage table from any report until it reaches
* a report with an action type of "receive" (the root report)
* Recursively goes up the report_lineage table from any report until it reaches
* a report that does not appear in report_lineage as a child report (the root report)
*
* This will return null if no report with action type "receive" is present or if
* the root is passed in
* This will return null if the root is passed in
*/
fun getRootReport(childReportId: UUID): ReportFile? {
return db.transactReturning { txn ->
Expand Down Expand Up @@ -174,17 +173,19 @@ class ReportGraph(
.on(REPORT_FILE.REPORT_ID.eq(ItemGraphTable.ITEM_GRAPH.PARENT_REPORT_ID))
.join(ACTION)
.on(ACTION.ACTION_ID.eq(REPORT_FILE.ACTION_ID))
.where(ACTION.ACTION_NAME.eq(TaskAction.receive))
.leftJoin(REPORT_LINEAGE)
.on(REPORT_FILE.REPORT_ID.eq(REPORT_LINEAGE.CHILD_REPORT_ID))
.where(REPORT_LINEAGE.PARENT_REPORT_ID.isNull())
.orderBy(REPORT_FILE.REPORT_ID.asc())
.fetchOneInto(Item::class.java)
return rootItem
}

/**
* Recursively goes up the report_linage table from any report until it reaches
* all reports with an action type of "receive" (the root report)
* Recursively goes up the report_lineage table from any report until it reaches
* all reports that do not appear in report_lineage as a child report (the root report)
*
* This will return null if no report with action type "receive" is present or if
* the root is passed in
* This will return null if the root is passed in
*
* If the passed in report ID has multiple root reports, they will all be returned
*/
Expand Down Expand Up @@ -478,7 +479,9 @@ class ReportGraph(
.on(REPORT_FILE.REPORT_ID.eq(cte.field(0, UUID::class.java)))
.join(ACTION)
.on(ACTION.ACTION_ID.eq(REPORT_FILE.ACTION_ID))
.where(ACTION.ACTION_NAME.eq(TaskAction.receive))
.leftJoin(REPORT_LINEAGE)
.on(REPORT_FILE.REPORT_ID.eq(REPORT_LINEAGE.CHILD_REPORT_ID))
.where(REPORT_LINEAGE.PARENT_REPORT_ID.isNull())

/**
* Accepts a list of ids and walks down the report lineage graph
Expand Down

0 comments on commit 46ec15a

Please sign in to comment.