From 1fb43d7c0e8b0645035147373898bb1d1f84bd85 Mon Sep 17 00:00:00 2001 From: sahilchaudhary Date: Mon, 13 May 2024 18:44:17 +0530 Subject: [PATCH] API structure changes --- src/main/java/org/sunbird/common/util/Constants.java | 2 +- .../sunbird/trending/controller/TrendingServiceImpl.java | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/sunbird/common/util/Constants.java b/src/main/java/org/sunbird/common/util/Constants.java index f6fb1458c..fd9fd54f4 100644 --- a/src/main/java/org/sunbird/common/util/Constants.java +++ b/src/main/java/org/sunbird/common/util/Constants.java @@ -1048,7 +1048,7 @@ public class Constants { public static final String PAGE_ID = "pageId"; public static final String USERS_LIST = "userList"; public static final String TOTAL_COUNT = "totalCount"; - public static final String MICROSITE_TOP_FEATURE_CONTENT_API = "api.microsite.topfeatured.content"; + public static final String MICROSITE_TOP_CONTENT_API = "api.microsite.top.content"; public static final String ICON = "icon"; private Constants() { diff --git a/src/main/java/org/sunbird/trending/controller/TrendingServiceImpl.java b/src/main/java/org/sunbird/trending/controller/TrendingServiceImpl.java index a9a1760ef..109f23ae3 100644 --- a/src/main/java/org/sunbird/trending/controller/TrendingServiceImpl.java +++ b/src/main/java/org/sunbird/trending/controller/TrendingServiceImpl.java @@ -187,7 +187,7 @@ private String getEndDateFormat() { } public SBApiResponse trendingContentSearch(Map requestBody, String token) throws Exception { - SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.MICROSITE_TOP_FEATURE_CONTENT_API); + SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.MICROSITE_TOP_CONTENT_API); try { Map request = requestBody.containsKey(REQUEST) ? (Map) requestBody.get(REQUEST) : MapUtils.EMPTY_MAP; if (MapUtils.isEmpty(request)) { @@ -241,22 +241,20 @@ public SBApiResponse trendingContentSearch(Map requestBody, Stri aggregateData.put(contextType, limitCourses); } } - List>> resultData = new ArrayList<>(); + List> contentList = new ArrayList<>(); if (!aggregateData.isEmpty()) { List compositeKeyList = new ArrayList<>(payloadToRedisKeyMapping.keySet()); for (int i = 0; i < aggregateData.size(); i++) { List searchIds = (List) aggregateData.get(compositeKeyList.get(i)); - List> contentList = new ArrayList<>(); for (String searchId : searchIds) { Map contentResponse = contentService.readContentFromCache(searchId, null); if (MapUtils.isNotEmpty(contentResponse)) { contentList.add(contentResponse); } } - resultData.add(contentList); } } - response.put(RESPONSE, resultData); + response.put(Constants.CONTENT, contentList); } catch (Exception e) { response.getParams().setStatus(Constants.FAILED); response.getParams().setErrmsg(e.getMessage());