diff --git a/src/main/java/org/mskcc/cbio/oncokb/web/rest/UsageAnalysisController.java b/src/main/java/org/mskcc/cbio/oncokb/web/rest/UsageAnalysisController.java index fe4494f9a..1f35707da 100644 --- a/src/main/java/org/mskcc/cbio/oncokb/web/rest/UsageAnalysisController.java +++ b/src/main/java/org/mskcc/cbio/oncokb/web/rest/UsageAnalysisController.java @@ -78,14 +78,14 @@ public ResponseEntity userUsageGet(@PathVariable @NotNull Long userId if (userId != null) { int year = TimeUtil.getCurrentNYTime().getYear(); JSONObject yearSummary = requestData(YEAR_USERS_USAGE_SUMMARY_FILE_PREFIX + year + FileExtension.JSON_FILE.getExtension()); - List monthSummaries = new LinkedList<>(); + Map monthSummaries = new HashMap<>(); int monthsBack = 0; JSONObject monthSummary; do { String month = TimeUtil.getCurrentNYTime().minus(monthsBack, ChronoUnit.MONTHS).format(DateTimeFormatter.ofPattern("yyyy-MM")); monthSummary = requestData(MONTH_USERS_USAGE_SUMMARY_FILE_PREFIX + month + FileExtension.JSON_FILE.getExtension()); if (monthSummary != null) { - monthSummaries.add(monthSummary); + monthSummaries.put(month, monthSummary); } monthsBack++; } while (monthsBack < 12); @@ -99,16 +99,20 @@ public ResponseEntity userUsageGet(@PathVariable @NotNull Long userId JSONObject yearUsageObject = (JSONObject) yearSummary.get(email); Gson gson = new Gson(); usageSummary = gson.fromJson(yearUsageObject.toString(), UsageSummary.class); - Map dayUsage = new HashMap<>(); if (!monthSummaries.isEmpty()) { - for (JSONObject month : monthSummaries) { - if (month.containsKey(email)) { - JSONObject monthUsageObject = (JSONObject) month.get(email); - JSONObject dayUsageObject = (JSONObject) monthUsageObject.get("day"); - dayUsageObject.forEach((key, value) -> dayUsage.put((String) key, (JSONObject) value)); + Map dayUsage = new HashMap<>(); + Map monthUsage = new HashMap<>(); + for (Map.Entry entry : monthSummaries.entrySet()) { + if (entry.getValue().containsKey(email)) { + JSONObject userUsageObject = (JSONObject) entry.getValue().get(email); + JSONObject dayUsageObject = (JSONObject) userUsageObject.get("day"); + dayUsageObject.forEach((day, summary) -> dayUsage.put((String) day, (JSONObject) summary)); + JSONObject monthUsageObject = (JSONObject) userUsageObject.get("month"); + monthUsage.put((String) entry.getKey(), monthUsageObject); } } usageSummary.setDay(dayUsage); + usageSummary.setMonth(monthUsage); } } diff --git a/src/main/webapp/app/config/constants.tsx b/src/main/webapp/app/config/constants.tsx index b39e82842..2bef55b8b 100644 --- a/src/main/webapp/app/config/constants.tsx +++ b/src/main/webapp/app/config/constants.tsx @@ -104,7 +104,7 @@ export const SHORTEN_TEXT_FROM_LIST_THRESHOLD = 5; export const TOKEN_ABOUT_2_EXPIRE_NOTICE_IN_DAYS = 14; export const USAGE_TOP_USERS_LIMIT = 10000; export const USAGE_ALL_TIME_KEY = 'All'; -export const USAGE_ALL_TIME_VALUE = 'Past Year'; +export const USAGE_ALL_TIME_VALUE = 'Year To Date'; export const USAGE_DETAIL_TIME_KEY = 'Detail'; export const USAGE_DAY_DETAIL_TIME_KEY = 'Day Detail'; diff --git a/src/main/webapp/app/pages/usageAnalysisPage/UsageAnalysisPage.tsx b/src/main/webapp/app/pages/usageAnalysisPage/UsageAnalysisPage.tsx index f5e8ab3e5..75f75d65e 100644 --- a/src/main/webapp/app/pages/usageAnalysisPage/UsageAnalysisPage.tsx +++ b/src/main/webapp/app/pages/usageAnalysisPage/UsageAnalysisPage.tsx @@ -50,11 +50,10 @@ enum UsageType { } export enum ToggleValue { - ALL_USERS = 'All Users', ALL_RESOURCES = 'All Resources', PUBLIC_RESOURCES = 'Only Public Resources', CUMULATIVE_USAGE = 'Cumulative Usage', - RESULTS_IN_TOTAL = 'By Year', + RESULTS_IN_TOTAL = 'Year To Date', RESULTS_BY_MONTH = 'By Month', RESULTS_BY_DAY = 'By Day', } @@ -119,7 +118,6 @@ export default class UsageAnalysisPage extends React.Component<{ routing: RouterStore; match: match; }> { - @observable topUsersToggleValue: ToggleValue = ToggleValue.ALL_USERS; @observable userTabResourcesTypeToggleValue: ToggleValue = ToggleValue.PUBLIC_RESOURCES; @observable resourceTabResourcesTypeToggleValue: ToggleValue = @@ -201,12 +199,6 @@ export default class UsageAnalysisPage extends React.Component<{ default: new Map(), }); - @autobind - @action - handleTopUsersToggleChange(value: ToggleValue) { - this.topUsersToggleValue = value; - } - @autobind @action handleUserTabResourcesTypeToggleChange(value: ToggleValue) {