fix: show all court report topic sections in creation order (#6601)#7006
Open
augustocbx wants to merge 1 commit into
Open
fix: show all court report topic sections in creation order (#6601)#7006augustocbx wants to merge 1 commit into
augustocbx wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What github issue is this PR for, if any?
Resolves #6601
What changed, and why?
CaseCourtReportContext#court_topicsbuilt the report's topic sections from an inner join oncontact_topic_answers, which caused two problems visible in generated court reports:occurred_at, so the questions came out in a different order on every report instead of the order the topics were defined.Now the section list is built from the org's contact topics themselves, ordered by creation (
id), matching the order ofdb/seeds/default_contact_topics.ymland the ordering already used byCaseContactsExportCsvService. Answers in the date range are grouped per topic and attached to their section; topics without answers render with an empty answer list so the question and details still appear in the report.Behavior preserved/tightened along the way:
exclude_from_court_reportstay out of the report (existing spec still passes).casa_org.Verified against the two production templates attached to the issue by @compwron (Montgomery and Prince George's): both render with all sections present and in order, including sections with no answers.
How is this tested? (please write rspec and jest tests!) 💖💪
Six new examples in
spec/models/case_court_report_context_spec.rbcovering: unanswered topics included with empty answers, creation-order sorting regardless of answer dates, inactive/excluded unanswered topics filtered out, inactive-with-answers preserved, and cross-org isolation. All six fail onmainand pass with this change.Screenshots please :)
No UI change — the fix is in the docx generation context. The rendered output was verified by generating reports from the two production templates attached to the issue and confirming all topic sections appear in creation order, including ones with no case contacts.