Skip to content

APP-542 & APP-665: Add endpoints for admin report create and edit#3238

Merged
JordanGuinn merged 110 commits into
mainfrom
jg/APP-542-fix
Jun 2, 2026
Merged

APP-542 & APP-665: Add endpoints for admin report create and edit#3238
JordanGuinn merged 110 commits into
mainfrom
jg/APP-542-fix

Conversation

@JordanGuinn

@JordanGuinn JordanGuinn commented May 18, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds new endpoints to the reports module for admin report creation and editing (including filter support as part of that).

Tickets

Checklist before requesting a review

  • PR focuses on a single story
  • Code has been fully tested to meet acceptance criteria
  • PR is reasonably small and reviewable (Generally less than 10 files and 500 changed lines)
  • All new functions/classes/components reasonably small
  • Functions/classes/components focused on one responsibility
  • Code easy to understand and modify (clarity over concise/clever)
  • PRs containing TypeScript follow the Do's and Don'ts
  • PR does not contain hardcoded values (Uses constants)
  • All code is covered by unit or feature tests

Comment thread apps/modernization-api/src/main/java/gov/cdc/nbs/report/ReportService.java Outdated
Comment thread libs/database-entities/src/main/java/gov/cdc/nbs/entity/odse/Report.java Outdated
});
assertThat(config.advancedFilter().reportFilterUid()).isEqualTo(6L);
}
@Nested

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended up experimenting with @Nested test groups here, as a means to hopefully better distinguish between the things being tested, and to be able to use beforeEach meaningfully across those groups. Thoughts?

@JordanGuinn JordanGuinn changed the title (WIP) APP-542: Add endpoint for report creation APP-542: Add endpoint for report creation May 20, 2026
@JordanGuinn JordanGuinn marked this pull request as ready for review May 20, 2026 22:13
@JordanGuinn JordanGuinn requested a review from a team as a code owner May 20, 2026 22:14
@JordanGuinn JordanGuinn requested review from brick-green, emyl3 and mcmcgrath13 and removed request for a team May 20, 2026 22:14

@brick-green brick-green left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few Qs and Suggs

* Necessary because `report_uid` is not marked as an IDENTITY column, nor does it have a
* corresponding sequence, so we have to use a custom query.
*/
@Query("SELECT (MAX(r.id.reportUid)+1) FROM Report r")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q, b: two questions:

  • is there a possibility for a race condition if two people try to create a report at the same time?
  • Will this work if there aren't any reports? I think MAX() will return null in that case

The second question feels like a simple fix (maybe use COALESCE?) but the first may be trickier and a pretty unlikely edge case anyways as users aren't making reports that often. Should we even try to solve for it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mcmcgrath13 pointed out there's already an existing utility for this in 7, so I just ended up using that!

That doesn't necessarily address those questions specifically, but imo it does make this less of a problem that we wanna solve for as part of this work.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Id Generation service exists (hopefully) to avoid these sorts of races. It dibs the ID for us and then we can use it knowing there won't be a clash

Comment thread apps/modernization-api/src/main/java/gov/cdc/nbs/report/mappers/ReportMapper.java Outdated
Comment thread apps/modernization-api/src/main/java/gov/cdc/nbs/report/ReportConstants.java Outdated
@@ -0,0 +1,130 @@
package gov.cdc.nbs.report;

import gov.cdc.nbs.entity.odse.*;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sugg, b: list out the imports instead of the wildcard?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will give that a shot manually - this was either the result of IntelliJ trying to be smart, or our Spotless formatter, definitely not something I intentionally did myself

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed, it was an IntelliJ setting. Though that does make me wonder if we have a preference on a potential upper limit there? Like at what point do we prefer *, if ever?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair question. I set my upper limit to 999 lol

But I can't see a good reason to use the wildcard. Maybe imposing a somewhat reasonable limit (like 20ish?) would be an indicator that too much is happening in a single file and that some refactoring in needed. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me! Will bump mine to 20 - I suppose if you've got more than that many imports from a single location, maybe worth re-evaluating why that is 😁

@Table(name = "Report", catalog = "NBS_ODSE")
public class Report {
@NonNull @EmbeddedId private ReportId id;
@EmbeddedId @NonNull ReportId id;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q, nb: should this be fully reverted?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, should be removed from the diff now!

Comment thread testing/regression/cypress/step_definitions/reports-api/create.steps.js Outdated

@mcmcgrath13 mcmcgrath13 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🪇

@brick-green brick-green left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work here! Found a few more wildcards and had one question

Comment on lines +252 to +255
if (!reportSectionRepository.existsBySectionCd(request.sectionCode())) {
throw new IllegalArgumentException(
"No report section found for code " + request.sectionCode());
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

q, nb: this validation feels a little out of place for the method fetchReportMetadata(). Are there other validations we could group together into a valiate() method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other validations as of right now - I can change this fn from fetch to verify, if that's helpful?

Comment thread apps/modernization-api/src/main/java/gov/cdc/nbs/report/ReportService.java Outdated
Comment thread apps/modernization-api/src/main/java/gov/cdc/nbs/report/ReportService.java Outdated
@sonarqubecloud

sonarqubecloud Bot commented Jun 2, 2026

Copy link
Copy Markdown

@JordanGuinn JordanGuinn merged commit 8eddd59 into main Jun 2, 2026
6 checks passed
@JordanGuinn JordanGuinn deleted the jg/APP-542-fix branch June 2, 2026 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants