Skip to content

Commit

Permalink
Merge pull request #1428 from navikt/ORG-1902-filtrere-inaktive-under…
Browse files Browse the repository at this point in the history
…odnede

ORG-1902
  • Loading branch information
erik-a-e authored Apr 5, 2024
2 parents 1e0dec3 + 3928936 commit 6dd346b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public byte[] generateSpreadsheet(SpreadsheetType type, String filter) {
case TEAM -> mapTeamMembers(List.of(teamService.get(StringUtils.toUUID(filter))), pas, clusters).collect(toList());
case ROLE -> filter(getAll(pas, clusters), m -> convert(m.member().getRoles(), Enum::name).contains(filter));
case LEADER -> filter(getAll(pas, clusters), m -> {
var leaderMembers = nomGraphClient.getLeaderMembers(filter);
var leaderMembers = nomGraphClient.getLeaderMembersActiveOnly(filter);
return leaderMembers.contains(m.member().getNavIdent());
});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import no.nav.data.common.utils.StreamUtils;
import no.nav.data.team.integration.process.GraphQLRequest;
import no.nav.data.team.org.OrgUrlId;
import no.nav.data.team.resource.domain.Resource;
import no.nav.data.team.resource.dto.NomGraphQlResponse.MultiRessurs;
import no.nav.data.team.resource.dto.NomGraphQlResponse.SingleOrg;
import no.nav.data.team.resource.dto.NomGraphQlResponse.SingleRessurs;
Expand Down Expand Up @@ -102,7 +103,7 @@ public Optional<OrgEnhetDto> getOrgEnhet(String orgUrl) {

public Optional<ResourceUnitsResponse> getUnits(String navIdent) {
return getRessurs(navIdent)
.map(r -> ResourceUnitsResponse.from(r, getLeaderMembers(navIdent), this::getOrgEnhet));
.map(r -> ResourceUnitsResponse.from(r, getLeaderMembersActiveOnly(navIdent), this::getOrgEnhet));
}

private Map<String, RessursDto> getRessurser(List<String> navIdents) {
Expand All @@ -114,6 +115,14 @@ private Map<String, RessursDto> getRessurser(List<String> navIdents) {
});
}

public List<String> getLeaderMembersActiveOnly(String navIdent) {
var nomClient = NomClient.getInstance();
return getLeaderMembers(navIdent).stream()
.map(nomClient::getByNavIdent)
.filter(Optional::isPresent).map(Optional::get)
.filter(it -> !it.isInactive()).map(Resource::getNavIdent).toList();
}

public List<String> getLeaderMembers(String navIdent) {
return leaderCache.get(navIdent, ident -> {
var req = new GraphQLRequest(getLeaderMemberQuery, Map.of("navident", navIdent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void setUp() {
createTeam(3, null, List.of(clusterOne.getId(), clusterTwo.getId())))
);
lenient().when(teamService.get(teamOne.getId())).thenReturn(teamOne);
lenient().when(nomGraphClient.getLeaderMembers("A123456")).thenReturn(List.of(createNavIdent(101), createNavIdent(102)));
lenient().when(nomGraphClient.getLeaderMembersActiveOnly("A123456")).thenReturn(List.of(createNavIdent(101), createNavIdent(102)));
UrlGeneratorTestUtil.get();
}

Expand Down

0 comments on commit 6dd346b

Please sign in to comment.