@@ -200,29 +200,34 @@ private JsonObject getMFAStats() throws StorageQueryException, TenantOrAppNotFou
200200 // TODO: Active users are present only on public tenant and MFA users may be
201201 // present on different storages
202202 JsonObject result = new JsonObject ();
203- Storage [] storages = StorageLayer .getStoragesForApp (main , this .appIdentifier );
204203
205- int totalUserCountWithMoreThanOneLoginMethod = 0 ;
206- int [] maus = new int [31 ];
204+ // Commenting out these stats for now as they are very CPU intensive and reduces the performance
205+ // of other API calls while this is running.
206+ // Also, we are not currently using these stats.
207207
208- long now = System . currentTimeMillis ( );
208+ // Storage[] storages = StorageLayer.getStoragesForApp(main, this.appIdentifier );
209209
210- for (Storage storage : storages ) {
211- totalUserCountWithMoreThanOneLoginMethod += ((AuthRecipeStorage ) storage )
212- .getUsersCountWithMoreThanOneLoginMethodOrTOTPEnabled (this .appIdentifier );
210+ // int totalUserCountWithMoreThanOneLoginMethod = 0;
211+ // int[] maus = new int[31];
213212
214- for (int i = 1 ; i <= 31 ; i ++) {
215- long timestamp = now - (i * 24 * 60 * 60 * 1000L );
213+ // long now = System.currentTimeMillis();
216214
217- // `maus[i-1]` since i starts from 1
218- maus [i - 1 ] += ((ActiveUsersStorage ) storage )
219- .countUsersThatHaveMoreThanOneLoginMethodOrTOTPEnabledAndActiveSince (appIdentifier , timestamp );
220- }
221- }
215+ // for (Storage storage : storages) {
216+ // totalUserCountWithMoreThanOneLoginMethod += ((AuthRecipeStorage) storage)
217+ // .getUsersCountWithMoreThanOneLoginMethodOrTOTPEnabled(this.appIdentifier);
222218
223- result .addProperty ("totalUserCountWithMoreThanOneLoginMethodOrTOTPEnabled" ,
224- totalUserCountWithMoreThanOneLoginMethod );
225- result .add ("mauWithMoreThanOneLoginMethodOrTOTPEnabled" , new Gson ().toJsonTree (maus ));
219+ // for (int i = 1; i <= 31; i++) {
220+ // long timestamp = now - (i * 24 * 60 * 60 * 1000L);
221+
222+ // // `maus[i-1]` since i starts from 1
223+ // maus[i - 1] += ((ActiveUsersStorage) storage)
224+ // .countUsersThatHaveMoreThanOneLoginMethodOrTOTPEnabledAndActiveSince(appIdentifier, timestamp);
225+ // }
226+ // }
227+
228+ // result.addProperty("totalUserCountWithMoreThanOneLoginMethodOrTOTPEnabled",
229+ // totalUserCountWithMoreThanOneLoginMethod);
230+ // result.add("mauWithMoreThanOneLoginMethodOrTOTPEnabled", new Gson().toJsonTree(maus));
226231 return result ;
227232 }
228233
@@ -305,36 +310,41 @@ private JsonObject getAccountLinkingStats() throws StorageQueryException, Tenant
305310 }
306311
307312 result .addProperty ("usesAccountLinking" , usesAccountLinking );
308- if (!usesAccountLinking ) {
309- result .addProperty ("totalUserCountWithMoreThanOneLoginMethod" , 0 );
310- JsonArray mauArray = new JsonArray ();
311- for (int i = 0 ; i < 31 ; i ++) {
312- mauArray .add (new JsonPrimitive (0 ));
313- }
314- result .add ("mauWithMoreThanOneLoginMethod" , mauArray );
315- return result ;
316- }
317-
318- int totalUserCountWithMoreThanOneLoginMethod = 0 ;
319- int [] maus = new int [31 ];
320-
321- long now = System .currentTimeMillis ();
322-
323- for (Storage storage : storages ) {
324- totalUserCountWithMoreThanOneLoginMethod += ((AuthRecipeStorage ) storage ).getUsersCountWithMoreThanOneLoginMethod (
325- this .appIdentifier );
326-
327- for (int i = 1 ; i <= 31 ; i ++) {
328- long timestamp = now - (i * 24 * 60 * 60 * 1000L );
329-
330- // `maus[i-1]` because i starts from 1
331- maus [i - 1 ] += ((ActiveUsersStorage ) storage ).countUsersThatHaveMoreThanOneLoginMethodAndActiveSince (
332- appIdentifier , timestamp );
333- }
334- }
335313
336- result .addProperty ("totalUserCountWithMoreThanOneLoginMethod" , totalUserCountWithMoreThanOneLoginMethod );
337- result .add ("mauWithMoreThanOneLoginMethod" , new Gson ().toJsonTree (maus ));
314+ // Commenting out these stats for now as they are very CPU intensive and reduces the performance
315+ // of other API calls while this is running.
316+ // Also, we are not currently using these stats.
317+
318+ // if (!usesAccountLinking) {
319+ // result.addProperty("totalUserCountWithMoreThanOneLoginMethod", 0);
320+ // JsonArray mauArray = new JsonArray();
321+ // for (int i = 0; i < 31; i++) {
322+ // mauArray.add(new JsonPrimitive(0));
323+ // }
324+ // result.add("mauWithMoreThanOneLoginMethod", mauArray);
325+ // return result;
326+ // }
327+
328+ // int totalUserCountWithMoreThanOneLoginMethod = 0;
329+ // int[] maus = new int[31];
330+
331+ // long now = System.currentTimeMillis();
332+
333+ // for (Storage storage : storages) {
334+ // totalUserCountWithMoreThanOneLoginMethod += ((AuthRecipeStorage) storage).getUsersCountWithMoreThanOneLoginMethod(
335+ // this.appIdentifier);
336+
337+ // for (int i = 1; i <= 31; i++) {
338+ // long timestamp = now - (i * 24 * 60 * 60 * 1000L);
339+
340+ // // `maus[i-1]` because i starts from 1
341+ // maus[i - 1] += ((ActiveUsersStorage) storage).countUsersThatHaveMoreThanOneLoginMethodAndActiveSince(
342+ // appIdentifier, timestamp);
343+ // }
344+ // }
345+
346+ // result.addProperty("totalUserCountWithMoreThanOneLoginMethod", totalUserCountWithMoreThanOneLoginMethod);
347+ // result.add("mauWithMoreThanOneLoginMethod", new Gson().toJsonTree(maus));
338348 return result ;
339349 }
340350
0 commit comments