Skip to content

Commit

Permalink
Refactoring and cleanup
Browse files Browse the repository at this point in the history
Co-authored-by: JeremiahUy <[email protected]>
Co-authored-by: PaulMartinKokseter <[email protected]>
  • Loading branch information
3 people committed Oct 9, 2023
1 parent 75734df commit 6c2e268
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public int getAntallIkkeFiltrertKrav(List<Krav> aktivKravList, EtterlevelseDokum
).toList().size();
}

public LocalDateTime getCreatedDate(List<Etterlevelse> etterlevelseList) {
public LocalDateTime getFirstCreatedDateForEtterlevelser(List<Etterlevelse> etterlevelseList) {
etterlevelseList.sort(Comparator.comparing(a -> a.getChangeStamp().getCreatedDate()));
return !etterlevelseList.isEmpty() ? etterlevelseList.get(0).getChangeStamp().getCreatedDate().withNano(0) : null;
}

public LocalDateTime getLastUpdatedDate(List<Etterlevelse> etterlevelseList) {
public LocalDateTime getLastUpdatedDateForEtterlevelser(List<Etterlevelse> etterlevelseList) {
etterlevelseList.sort(Comparator.comparing(a -> a.getChangeStamp().getLastModifiedDate()));
return !etterlevelseList.isEmpty() ? etterlevelseList.get(etterlevelseList.size() - 1).getChangeStamp().getLastModifiedDate().withNano(0) : null;
}
Expand Down Expand Up @@ -137,11 +137,9 @@ public Page<BehandlingStatistikk> getAllBehandlingStatistikk(Pageable page) {
//Get all etterlevelse for behandling
List<Etterlevelse> etterlevelseList = etterlevelseService.getByEtterlevelseDokumentasjon(String.valueOf(etterlevelseDokumentasjon.getId()));

//Sort etterlevelse on created date to when the first documentation was created
LocalDateTime opprettetDato = getCreatedDate(etterlevelseList);
LocalDateTime opprettetDato = getFirstCreatedDateForEtterlevelser(etterlevelseList);

//Sort etterlevelse on updated date to when the documentation was last updated
LocalDateTime endretDato = getLastUpdatedDate(etterlevelseList);
LocalDateTime endretDato = getLastUpdatedDateForEtterlevelser(etterlevelseList);

//Filter etterlevelse to only have documentation for active Krav
List<Etterlevelse> aktivEtterlevelseList = etterlevelseList.stream().filter(etterlevelse ->
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,23 @@

import lombok.Getter;
import no.nav.data.common.security.SecurityProperties;
import no.nav.data.etterlevelse.krav.domain.Krav;
import no.nav.data.etterlevelse.krav.domain.Tilbakemelding;
import org.springframework.stereotype.Component;

@Component
public class UrlGenerator {

private static final String teamSlackId = "T5LNAMWNA";

@Getter
private final String baseUrl;
@Getter
private final boolean dev;

private static UrlGenerator INSTANCE;

public UrlGenerator(SecurityProperties securityProperties) {
baseUrl = securityProperties.findBaseUrl();
dev = securityProperties.isDev();
INSTANCE = this;
}

public String kravUrl(Krav krav) {
return "%s/krav/%d/%d".formatted(baseUrl, krav.getKravNummer(), krav.getKravVersjon());
}

public String tilbakemeldingUrl(Tilbakemelding tilbakemelding) {
return "%s/krav/%d/%d?tilbakemeldingId=%s".formatted(baseUrl, tilbakemelding.getKravNummer(), tilbakemelding.getKravVersjon(), tilbakemelding.getId());
}

public static UrlGenerator instance() {
return INSTANCE;
}
}

0 comments on commit 6c2e268

Please sign in to comment.