From d43833a2433e29a29df555b755f7d07fc5940c22 Mon Sep 17 00:00:00 2001 From: notshivansh Date: Sat, 24 Aug 2024 16:31:23 +0530 Subject: [PATCH] fix comments --- .../src/main/java/com/akto/action/DbAction.java | 2 ++ .../src/main/java/com/akto/usage/UsageMetricCalculator.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/database-abstractor/src/main/java/com/akto/action/DbAction.java b/apps/database-abstractor/src/main/java/com/akto/action/DbAction.java index b4d8649d2d..7a0bb57198 100644 --- a/apps/database-abstractor/src/main/java/com/akto/action/DbAction.java +++ b/apps/database-abstractor/src/main/java/com/akto/action/DbAction.java @@ -964,6 +964,7 @@ public String fetchDeactivatedCollections() { try { apiCollectionIds = DbLayer.fetchDeactivatedCollections(); } catch (Exception e) { + loggerMaker.errorAndAddToDb(e, "Error in fetchDeactivatedCollections " + e.toString()); return Action.ERROR.toUpperCase(); } return Action.SUCCESS.toUpperCase(); @@ -974,6 +975,7 @@ public String updateUsage() { MetricTypes metric = MetricTypes.valueOf(metricType); DbLayer.updateUsage(metric, deltaUsage); } catch (Exception e) { + loggerMaker.errorAndAddToDb(e, "Error in updateUsage " + e.toString()); return Action.ERROR.toUpperCase(); } return Action.SUCCESS.toUpperCase(); diff --git a/libs/utils/src/main/java/com/akto/usage/UsageMetricCalculator.java b/libs/utils/src/main/java/com/akto/usage/UsageMetricCalculator.java index b0716cb921..2e7b084aa1 100644 --- a/libs/utils/src/main/java/com/akto/usage/UsageMetricCalculator.java +++ b/libs/utils/src/main/java/com/akto/usage/UsageMetricCalculator.java @@ -23,9 +23,12 @@ import com.akto.dto.usage.UsageMetric; import com.akto.dto.usage.metadata.ActiveAccounts; import com.akto.log.LoggerMaker; +import com.akto.util.Constants; import com.akto.util.enums.GlobalEnums.YamlTemplateSource; import com.google.gson.Gson; import com.mongodb.client.model.Filters; +import com.mongodb.client.model.Projections; + import org.bson.conversions.Bson; public class UsageMetricCalculator { @@ -60,7 +63,7 @@ public static Set getDeactivated() { public static Set getDeactivatedLatest(){ List deactivated = ApiCollectionsDao.instance - .findAll(Filters.eq(ApiCollection._DEACTIVATED, true)); + .findAll(Filters.eq(ApiCollection._DEACTIVATED, true), Projections.include(Constants.ID)); Set deactivatedIds = new HashSet<>( deactivated.stream().map(apiCollection -> apiCollection.getId()).collect(Collectors.toList()));