Refactor count workorders to reuse search code
Validation Steps
$ mix test test/lightning/digest_email_worker_test.exs
Notes for the reviewer
As a continuation of #2118:
- Reuse
search_workorders_queryfor counting - Reuse
search_workorders_queryto return workorders for retries (with dataclips not wiped)
Keeps same behavior as https://github.com/OpenFn/lightning/pull/2123.
Related issue
Refs #2121
Review checklist
- [x] I have performed a self-review of my code
- [x] I have verified that all appropriate authorization policies (
:owner,:admin,:editor,:viewer) have been implemented and tested - [x] If needed, I have updated the changelog
- [ ] Product has QA'd this feature
Codecov Report
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 89.65%. Comparing base (
f9f4a5e) to head (3bc24bf).
Additional details and impacted files
@@ Coverage Diff @@
## main #2122 +/- ##
=======================================
Coverage 89.64% 89.65%
=======================================
Files 270 270
Lines 8953 8942 -11
=======================================
- Hits 8026 8017 -9
+ Misses 927 925 -2
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@taylordowns2000 @stuartc this is need to remove duplicated code when searching for workorders and replaces on LV the use of:
socket.assigns.project
|> Invocation.search_workorders_query(filter)
|> Invocation.exclude_wiped_dataclips()
|> Lightning.Repo.all()
|> WorkOrders.retry_many(job_id, ...)
in favor of having query logic on the context module and retrieving only what is needed for retries:
socket.assigns.project
|> Invocation.search_workorders_for_retry(filter)
|> WorkOrders.retry_many(job_id, ...)
where the new function search_workorders_for_retry is similarly defined as:
https://github.com/OpenFn/lightning/blob/96848158f0a0d47a3334b0953f83a884b0b524a3/lib/lightning/invocation.ex#L356-L365