From af4c32df7d839d29a81b64056e0cc99b8ad61972 Mon Sep 17 00:00:00 2001 From: Sahil-tarento <140611066+Sahil-tarento@users.noreply.github.com> Date: Wed, 6 Mar 2024 17:27:58 +0530 Subject: [PATCH] Update the sorting logic for explore API (#484) --- .../sunbird/course/service/ExploreCourseServiceImpl.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java b/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java index 914f4d5cc..7f7ee1a95 100644 --- a/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java +++ b/src/main/java/org/sunbird/course/service/ExploreCourseServiceImpl.java @@ -71,6 +71,13 @@ public SBApiResponse getExploreCourseList() { errMsg = "Failed to get contant details for Identifier List from DB."; } else { Map responseCourseList = (Map) searchResponse.get(Constants.RESULT); + List> contentList = (List>) responseCourseList.get(Constants.CONTENT); + if (CollectionUtils.isNotEmpty(contentList)) { + List> sortedContentList = identifierList.stream().map(identifier -> contentList.stream() + .filter(content -> identifier.equals(content.get(Constants.IDENTIFIER))) + .findFirst().orElse(null)).filter(Objects::nonNull).collect(Collectors.toList()); + responseCourseList.put(Constants.CONTENT, sortedContentList); + } response.setResult(responseCourseList); } } catch (Exception e) {