Skip to content

Commit

Permalink
Bugfix/organisasjon bestilling (#3606)
Browse files Browse the repository at this point in the history
Oppdatert organisasjon-bestilling, rettet feil, refaktorert og forenklet kodebasen

Co-authored-by: stigus <[email protected]>
  • Loading branch information
krharum and stigus authored Sep 16, 2024
1 parent 7db9e80 commit 8cc0806
Show file tree
Hide file tree
Showing 97 changed files with 449 additions and 2,389 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/app.ereg-batch-status-service.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/proxy.modapp-ereg-proxy.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ public static void main(String[] args) {

SpringApplication.run(DollyBackendApplicationStarter.class, args);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.retry.Retry;

import java.time.Duration;
Expand Down Expand Up @@ -67,7 +68,7 @@ public Flux<OrganisasjonDetaljer> hentOrganisasjon(List<String> orgnumre) {
.flatMapMany(token -> new GetOrganisasjonCommand(webClient, orgnumre, token.getTokenValue()).call());
}

@Timed(name = "providers", tags = {"operation", "organisasjon-hent"})
@Timed(name = "providers", tags = {"operation", "organisasjon-status-hent"})
public OrganisasjonDeployStatus hentOrganisasjonStatus(List<String> orgnumre) {
var navCallId = getNavCallId();
log.info("Organisasjon hent request sendt, callId: {}, consumerId: {}", navCallId, CONSUMER);
Expand All @@ -85,8 +86,9 @@ public OrganisasjonDeployStatus hentOrganisasjonStatus(List<String> orgnumre) {
.header(HEADER_NAV_CONSUMER_ID, CONSUMER)
.retrieve()
.bodyToMono(OrganisasjonDeployStatus.class)
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
.filter(WebClientFilter::is5xxException)))
.doOnError(WebClientFilter::logErrorMessage)
.onErrorResume(throwable -> Mono.empty())
)
.block();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public Flux<OrganisasjonDetaljer> call() {
.bodyToFlux(OrganisasjonDetaljer.class)
.doOnError(WebClientFilter::logErrorMessage)
.retryWhen(Retry.backoff(3, Duration.ofSeconds(5))
.filter(WebClientFilter::is5xxException));
.filter(WebClientFilter::is5xxException))
.onErrorResume(throwable -> Flux.empty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static java.util.Collections.emptyList;
import static java.util.Collections.singletonList;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import static no.nav.dolly.domain.resultset.SystemTyper.ORGANISASJON_FORVALTER;

@NoArgsConstructor(access = AccessLevel.PRIVATE)
Expand All @@ -29,8 +30,6 @@ public static List<RsOrganisasjonStatusRapport> buildOrganisasjonStatusMap(Organ

List.of(progress.getOrganisasjonsforvalterStatus()
.replace(",q", "$q")
.replace(",t", "$t")
.replace(",u", "$u")
.split("\\$")).forEach(status -> {
String[] environMsg = status.split(":", 2);
if (environMsg.length < 2) {
Expand Down Expand Up @@ -65,9 +64,11 @@ public static List<RsOrganisasjonStatusRapport> buildOrganisasjonStatusMap(Organ
}

private static String getOrgStatusDetailForMiljo(List<OrganisasjonDeployStatus.OrgStatus> orgStatuser, String miljo) {
return orgStatuser.stream()
.filter(orgStatus -> orgStatus.getEnvironment().equals(miljo))
.findFirst().orElseGet(OrganisasjonDeployStatus.OrgStatus::new)
.getDetails();

return nonNull(orgStatuser) ? orgStatuser.stream()
.filter(orgStatus -> miljo.equals(orgStatus.getEnvironment()))
.map(status -> "%s %s".formatted(status.getDetails(),
status.getDetails().contains("feil") ? status.getError() : ""))
.findFirst().orElse("") : "";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Flux;

import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
Expand Down Expand Up @@ -92,7 +93,7 @@ public RsOrganisasjonBestillingStatus fetchBestillingStatusById(Long bestillingI
}

return RsOrganisasjonBestillingStatus.builder()
.status(BestillingOrganisasjonStatusMapper.buildOrganisasjonStatusMap(bestillingProgress, nonNull(orgStatusList) ? orgStatusList : emptyList()))
.status(BestillingOrganisasjonStatusMapper.buildOrganisasjonStatusMap(bestillingProgress, orgStatusList))
.bestilling(jsonBestillingMapper.mapOrganisasjonBestillingRequest(bestilling.getBestKriterier()))
.sistOppdatert(bestilling.getSistOppdatert())
.organisasjonNummer(bestillingProgress.getOrganisasjonsnummer())
Expand Down Expand Up @@ -249,12 +250,15 @@ private void updateBestilling(OrganisasjonBestilling bestilling, List<OrgStatus>

bestilling.setFeil(feil);

var ferdig = orgStatus.stream()
.anyMatch(o -> DEPLOY_ENDED_STATUS_LIST.stream().anyMatch(status -> status.equals(o.getStatus())));
var ferdig = !orgStatus.isEmpty() && orgStatus.stream()
.allMatch(o -> DEPLOY_ENDED_STATUS_LIST.stream()
.anyMatch(status -> status.equals(o.getStatus()))) &&
Arrays.stream(bestilling.getMiljoer().split(","))
.allMatch(miljoe -> orgStatus.stream()
.anyMatch(o -> o.getEnvironment().equals(miljoe)));

bestilling.setFerdig(ferdig);
bestilling.setSistOppdatert(now());

}

private String forvalterStatusDetails(OrgStatus orgStatus) {
Expand All @@ -274,17 +278,21 @@ private List<OrgStatus> getOrgforvalterStatus(OrganisasjonBestilling bestilling,

log.info("Status for org deploy på org: {} - {}", bestillingProgress.getOrganisasjonsnummer(), organisasjonDeployStatus);

var orgStatus = organisasjonDeployStatus.getOrgStatus()
.getOrDefault(bestillingProgress.getOrganisasjonsnummer(), emptyList());
if (nonNull(organisasjonDeployStatus)) {
var orgStatus = organisasjonDeployStatus.getOrgStatus()
.getOrDefault(bestillingProgress.getOrganisasjonsnummer(), emptyList());

updateBestilling(bestilling, orgStatus);
updateBestilling(bestilling, orgStatus);

var forvalterStatus = orgStatus.stream()
.map(org -> org.getEnvironment() + ":" + forvalterStatusDetails(org))
.collect(Collectors.joining(","));
bestillingProgress.setOrganisasjonsforvalterStatus(forvalterStatus);
var forvalterStatus = orgStatus.stream()
.map(org -> org.getEnvironment() + ":" + forvalterStatusDetails(org))
.collect(Collectors.joining(","));
bestillingProgress.setOrganisasjonsforvalterStatus(forvalterStatus);
return orgStatus;

return orgStatus;
} else {
return emptyList();
}
}

private String toJson(Object object) {
Expand Down
5 changes: 1 addition & 4 deletions apps/dolly-backend/src/main/resources/application-local.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ spring:
enabled: false
datasource:
url: jdbc:postgresql://localhost:5432/dolly-test
username: postgres
hikari:
maximum-pool-size: 3
minimum-idle: 1
driver-class-name: org.postgresql.Driver
username: postgres

management:
endpoints:
Expand Down
8 changes: 0 additions & 8 deletions apps/ereg-batch-status-service/Dockerfile

This file was deleted.

19 changes: 0 additions & 19 deletions apps/ereg-batch-status-service/README.md

This file was deleted.

30 changes: 0 additions & 30 deletions apps/ereg-batch-status-service/build.gradle

This file was deleted.

61 changes: 0 additions & 61 deletions apps/ereg-batch-status-service/config.yml

This file was deleted.

Binary file not shown.

This file was deleted.

Loading

0 comments on commit 8cc0806

Please sign in to comment.