Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DMP-4316: fix default sorting on tables on admin portal #2412

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

Ben-Edwards-cgi
Copy link
Contributor

@Ben-Edwards-cgi Ben-Edwards-cgi commented Jan 3, 2025

Links

Jira

Change description

The tables on admin portal are not sorted by a particular field by default and just return the results as the database returns them.

The following tables need sorting as specified:

  • {color:#00875a}Search - case: caseID{color}
  • {color:#00875a}Search - hearing: hearing date{color}
  • {color:#00875a}Search - events: eventID{color}
  • {color:#00875a}Search - Audio: audioID{color}
  • {color:#00875a}Users: full name{color}
  • {color:#00875a}Groups: name{color}
  • {color:#00875a}Transformed media: MediaID{color}
  • {color:#00875a}Transcript Requests: RequestID{color}
  • {color:#00875a}Completed Transcripts: TranscriptID{color}
  • {color:#00875a}Retention Policies: Policy key{color}
  • {color:#00875a}Event Mappings: Event Name{color}
  • {color:#00875a}Automated tasks: name{color}
  • {color:#00875a}AudioID screen - Associated Cases: CaseID{color}
  • {color:#00875a}Other files to be deleted: Channel number{color}
  • files marked for deletion for audio and transcripts: 
    ** Audio: Hearings date & Channel - [~leanne.jacobs]  to move to another ticket following screen redesign
    ** {color:#00875a}Transcripts: CaseID{color}

All sorted descending

Acceptance criteria

Each table as listed above sorts by default by the attribute labelled after the colon :

Does this PR introduce a breaking change? (check one with "x")

[ ] Yes
[X] No

@@ -244,8 +251,13 @@ public List<AdminCasesSearchResponseItem> adminCaseSearch(AdminCasesSearchReques
if (matchingCaseIds.size() > adminSearchMaxResults) {
throw new DartsApiException(CaseApiError.TOO_MANY_RESULTS);
}
List<CourtCaseEntity> matchingCases = caseRepository.findAllById(matchingCaseIds);
hearingRepository.findByCaseIds(matchingCaseIds);
List<CourtCaseEntity> matchingCases = caseRepository.findAll(new Specification<CourtCaseEntity>() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be a specific database call to get the matching cases by the order by name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As this is only used here i stuck it in the service but it does make more sense to be in the repository layer as we are not doing any dynamic filters.

Will move :)


for (int i = 0; i < events.size(); i++) {
EventMapping event = events.get(i);
System.out.println(".andExpect(jsonPath(\"$[" + i + "].name\", Matchers.is(\"" + event.getName() + "\")))");
Copy link
Contributor

Choose a reason for hiding this comment

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

System.out in production code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was left over from some testing good spot will remove :)


///admin/retention-policy-types
Copy link
Contributor

Choose a reason for hiding this comment

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

Too many dashes for comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have removed this comment as it does not provide any real value :)

WHERE cc.id in :ids
ORDER BY cc.id DESC
""")
List<CourtCaseEntity> findAllWithIdMatchingOneOf(List<Integer> ids);
Copy link
Contributor

@karen-hedges karen-hedges Jan 13, 2025

Choose a reason for hiding this comment

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

You have added this new method to the repository so you need to have an integration repository test for this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added :)

@@ -13,7 +14,8 @@
@Repository
public interface RetentionPolicyTypeRepository extends
RevisionRepository<RetentionPolicyTypeEntity, Integer, Long>,
JpaRepository<RetentionPolicyTypeEntity, Integer> {
JpaRepository<RetentionPolicyTypeEntity, Integer>,
JpaSpecificationExecutor<RetentionPolicyTypeEntity> {
Copy link
Contributor

Choose a reason for hiding this comment

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

You have added JpaSpecificationExecutor without using it. Is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants