Skip to content

Commit

Permalink
API structure changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sahil-tarento authored and karthik-tarento committed May 14, 2024
1 parent 09c8e62 commit 1fb43d7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main/java/org/sunbird/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ private String getEndDateFormat() {
}

public SBApiResponse trendingContentSearch(Map<String, Object> 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<String, Object> request = requestBody.containsKey(REQUEST) ? (Map<String, Object>) requestBody.get(REQUEST) : MapUtils.EMPTY_MAP;
if (MapUtils.isEmpty(request)) {
Expand Down Expand Up @@ -241,22 +241,20 @@ public SBApiResponse trendingContentSearch(Map<String, Object> requestBody, Stri
aggregateData.put(contextType, limitCourses);
}
}
List<List<Map<String, Object>>> resultData = new ArrayList<>();
List<Map<String, Object>> contentList = new ArrayList<>();
if (!aggregateData.isEmpty()) {
List<String> compositeKeyList = new ArrayList<>(payloadToRedisKeyMapping.keySet());
for (int i = 0; i < aggregateData.size(); i++) {
List<String> searchIds = (List<String>) aggregateData.get(compositeKeyList.get(i));
List<Map<String, Object>> contentList = new ArrayList<>();
for (String searchId : searchIds) {
Map<String, Object> 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());
Expand Down

0 comments on commit 1fb43d7

Please sign in to comment.