Skip to content

Commit

Permalink
moved create indices to daoinit
Browse files Browse the repository at this point in the history
  • Loading branch information
avneesh-akto committed Dec 6, 2023
1 parent 693fb7f commit 9aaa58b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 18 deletions.
7 changes: 1 addition & 6 deletions apps/api-runtime/src/main/java/com/akto/runtime/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,6 @@ public static boolean tryForCollectionName(String message) {
}


public static void createIndices() {
SingleTypeInfoDao.instance.createIndicesIfAbsent();
SensitiveSampleDataDao.instance.createIndicesIfAbsent();
SampleDataDao.instance.createIndicesIfAbsent();
}

public static void insertRuntimeFilters() {
RuntimeFilterDao.instance.initialiseFilters();
Expand Down Expand Up @@ -350,7 +345,7 @@ public static void initializeRuntime(){

public static void initializeRuntimeHelper() {
SingleTypeInfoDao.instance.getMCollection().updateMany(Filters.exists("apiCollectionId", false), Updates.set("apiCollectionId", 0));
createIndices();
DaoInit.createIndices();
insertRuntimeFilters();
try {
AccountSettingsDao.instance.updateVersion(AccountSettings.API_RUNTIME_VERSION);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.akto.action;

import com.akto.DaoInit;
import com.akto.dao.*;
import com.akto.dao.context.Context;
import com.akto.dto.*;
Expand Down Expand Up @@ -256,7 +257,7 @@ public void run() {
BackwardCompatibilityDao.instance.insertOne(backwardCompatibility);
}
InitializerListener.setBackwardCompatibilities(backwardCompatibility);
Main.createIndices();
DaoInit.createIndices();
Main.insertRuntimeFilters();
RuntimeListener.initialiseDemoCollections();
RuntimeListener.addSampleData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.akto.dto.pii.PIIType;
import com.akto.dto.test_editor.TestConfig;
import com.akto.dto.test_editor.YamlTemplate;
import com.akto.dto.testing.TestingRun;
import com.akto.dto.traffic.SampleData;
import com.akto.dto.type.SingleTypeInfo;
import com.akto.github.GithubFile;
Expand Down Expand Up @@ -1253,17 +1254,7 @@ public static void setBackwardCompatibilities(BackwardCompatibility backwardComp
}

public void runInitializerFunctions() {
SingleTypeInfoDao.instance.createIndicesIfAbsent();
TrafficMetricsDao.instance.createIndicesIfAbsent();
TestRolesDao.instance.createIndicesIfAbsent();

ApiInfoDao.instance.createIndicesIfAbsent();
RuntimeLogsDao.instance.createIndicesIfAbsent();
LogsDao.instance.createIndicesIfAbsent();
DashboardLogsDao.instance.createIndicesIfAbsent();
LoadersDao.instance.createIndicesIfAbsent();
TestingRunResultDao.instance.createIndicesIfAbsent();
TestingRunResultSummariesDao.instance.createIndicesIfAbsent();
DaoInit.createIndices();
fillCollectionIdArray();

BackwardCompatibility backwardCompatibility = BackwardCompatibilityDao.instance.findOne(new BasicDBObject());
Expand Down
25 changes: 25 additions & 0 deletions libs/dao/src/main/java/com/akto/DaoInit.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
package com.akto;

import com.akto.dao.*;
import com.akto.dao.loaders.LoadersDao;
import com.akto.dao.testing.TestRolesDao;
import com.akto.dao.testing.TestingRunDao;
import com.akto.dao.testing.TestingRunResultDao;
import com.akto.dao.testing.TestingRunResultSummariesDao;
import com.akto.dao.testing_run_findings.TestingRunIssuesDao;
import com.akto.dao.traffic_metrics.TrafficMetricsDao;
import com.akto.dto.*;
import com.akto.dto.data_types.*;
import com.akto.dto.demo.VulnerableRequestForTemplate;
Expand Down Expand Up @@ -250,4 +258,21 @@ public static void init(ConnectionString connectionString) {
clients[0] = MongoClients.create(clientSettings);
}


public static void createIndices() {
SingleTypeInfoDao.instance.createIndicesIfAbsent();
TrafficMetricsDao.instance.createIndicesIfAbsent();
TestRolesDao.instance.createIndicesIfAbsent();

ApiInfoDao.instance.createIndicesIfAbsent();
RuntimeLogsDao.instance.createIndicesIfAbsent();
LogsDao.instance.createIndicesIfAbsent();
DashboardLogsDao.instance.createIndicesIfAbsent();
LoadersDao.instance.createIndicesIfAbsent();
TestingRunResultDao.instance.createIndicesIfAbsent();
TestingRunResultSummariesDao.instance.createIndicesIfAbsent();
TestingRunDao.instance.createIndicesIfAbsent();
TestingRunIssuesDao.instance.createIndicesIfAbsent();
}

}

0 comments on commit 9aaa58b

Please sign in to comment.