From 2ad0abb56dbb72f12aee460408a4413644a0d9be Mon Sep 17 00:00:00 2001 From: Stephanya Casanova Date: Mon, 17 Jun 2024 14:58:18 +0200 Subject: [PATCH] [backend] refact --- .../src/main/java/io/openbas/rest/helper/TeamHelper.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/openbas-api/src/main/java/io/openbas/rest/helper/TeamHelper.java b/openbas-api/src/main/java/io/openbas/rest/helper/TeamHelper.java index 019b0af55c..9884e490ed 100644 --- a/openbas-api/src/main/java/io/openbas/rest/helper/TeamHelper.java +++ b/openbas-api/src/main/java/io/openbas/rest/helper/TeamHelper.java @@ -131,6 +131,13 @@ public static List rawTeamToSimplerTeam(List teams, } private static Set getInjectTeamsIds(final String teamId, Set injectIds, final InjectRepository injectRepository) { - return injectRepository.findRawInjectTeams(injectIds).stream().filter(i-> i.getInject_teams().contains(teamId)).map(RawInjectTeam::getInject_id).collect(Collectors.toSet()); + List rawInjectTeams = injectRepository.findRawInjectTeams(injectIds); + + // Extract inject_ids that belong to the given teamId + return rawInjectTeams.stream() + .filter(rawInjectTeam -> rawInjectTeam.getInject_teams().contains(teamId)) + .map(RawInjectTeam::getInject_id) + .collect(Collectors.toSet()); } + }