prime-reportstream icon indicating copy to clipboard operation
prime-reportstream copied to clipboard

Pass root report id to Azure events when available

Open arnejduranovic opened this issue 8 months ago • 4 comments

User Story

As a maintainer of the Universal Pipeline, I want to avoid making unnecessary calls to the DB, so that I can avoid related performance issues

Description/Use Case

Several UP steps need to call reportService.getRootReport(message.reportId) to perform their business logic. These same steps then end up calling reportEventService.sendItemEvent(...) which ends up calling getRootReports in ReportStreamEventService.getItemEventData. Instead of querying the DB twice in this flow, we should investigate to see if we can optionally pass in the root report so it does not need to be calculated again in ReportStreamEventService.getItemEventData.

There is a similar issue with ReportStreamEventService.getReportEventData as well that will need to be investigated in this ticket.

Once ReportStreamEventService.getReportEventData and reportEventService.sendItemEvent(...) have been updated to accept the optional root reports, go through all usages of Azure Events and pass in the root reports if it makes sense to do so for those particular usages.

Risks/Impacts/Considerations

Dev Notes

See FHIRTranslator.kt for an example:

  1. In sendTranslated, we call: val originalReport = reportService.getRootReport(message.reportId)
  2. Then later in the same method, we call reportEventService.sendItemEvent( which will ultimately repeat the DB query to get the root reports

In this case, since we already get the root report, we should just pass that to the event logic so it doesn't have to calculate it again.

Acceptance Criteria

  • [ ] Updated sendItemEvent to accept optional rootReport(s)
  • [ ] Updated sendReportEvent to accept optional rootReport(s)
  • [ ] Updated usages of the above to pass in the root report IDs or Report objects where appropriate

arnejduranovic avatar Apr 08 '25 17:04 arnejduranovic

Hey team! Please add your planning poker estimate with Zenhub @adegolier @jack-h-wang @oluwie @JFisk42 @feralearthman

megreed1 avatar Apr 10 '25 16:04 megreed1

@adegolier @JFisk42 @feralearthman @jack-h-wang please point

oluwie avatar Apr 10 '25 16:04 oluwie

Please add your planning poker estimate with Zenhub @oluwie

megreed1 avatar Apr 10 '25 16:04 megreed1

Previous attempt at solution here: https://github.com/CDCgov/prime-reportstream/pull/17854

arnejduranovic avatar Apr 22 '25 17:04 arnejduranovic