Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
feat: changed agency list to return a randomly sorted list of agencies
Browse files Browse the repository at this point in the history
  • Loading branch information
mobo4b committed Feb 10, 2021
1 parent 5879a31 commit ca216da
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion api/agencyservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ paths:
get:
tags:
- agency-controller
summary: 'Returns the list of agencies. If no agency is found the white spot
summary: 'Returns a randomly sorted list of agencies. If no agency is found the white spot
agency id is being returned. When no white spot agency is defined No Content
is being returned. [Authorization: none]'
operationId: getAgencies
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ public AgencyController(AgencyService agencyService) {
}

/**
* Gets a list of AgencyResponseDTOs (from database) and returns the list and a 200 OK on success
* depending on the post code that is given via query parameter.
* Gets a randomly sorted list of AgencyResponseDTOs (from database) and returns the list and a
* 200 OK on success depending on the post code that is given via query parameter.
*
* @param postcode the postcode for regarding agencies
* @param postcode the postcode for regarding agencies
* @param consultingType the type used to filter the agencies
* @return the List of agencies with information
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public List<AgencyResponseDTO> getAgencies(List<Long> agencyIds) {
}

/**
* Returns a list of {@link AgencyResponseDTO} which match to the provided postCode. If no agency
* is found, returns the atm hard coded white spot agency id.
* Returns a randomly sorted list of {@link AgencyResponseDTO} which match to the provided
* postCode. If no agency is found, returns the atm hard coded white spot agency id.
*
* @param postCode the postcode for regarding agencies
* @param consultingType the type used for filtering of agencies
Expand All @@ -65,6 +65,7 @@ public List<AgencyResponseDTO> getAgencies(String postCode, ConsultingType consu

List<Agency> agencies = collectAgenciesByPostCodeAndConsultingType(
postCode, consultingType);
Collections.shuffle(agencies);
List<AgencyResponseDTO> agencyResponseDTOs = agencies.stream()
.map(this::convertToAgencyResponseDTO)
.collect(Collectors.toList());
Expand Down

0 comments on commit ca216da

Please sign in to comment.