Skip to content

ORG-1799 skjule sluttdato i export #1486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@
import no.nav.data.team.team.domain.Team;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import java.util.stream.Stream;

import static java.util.Comparator.comparing;
import static java.util.Objects.isNull;
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
import static no.nav.data.common.utils.StreamUtils.convert;
Expand Down Expand Up @@ -149,10 +151,15 @@ private void add(ExcelBuilder doc, Member member) {
.addCell(member.member.getDescription())
.addCell(member.member.getResource().getEmail())
.addCell(DateUtil.formatDate(member.member.getResource().getStartDate()))
.addCell(DateUtil.formatDate(member.member.getResource().getEndDate()))
.addCell(shouldHideEndDateIfBeforeNow(member.member.getResource().getEndDate()))
;
}

private String shouldHideEndDateIfBeforeNow(LocalDate endDate) {
if (isNull(endDate) || endDate.isBefore(LocalDate.now())) return null;
else return DateUtil.formatDate(endDate);
}

record Member(Relation relation, MemberResponse member, Team team, ProductArea pa, List<Cluster> clusters) {

enum Relation {
Expand Down Expand Up @@ -196,8 +203,5 @@ public String memberType() {
public String roles() {
return String.join(", ", convert(member.getRoles(), Lang::roleName));
}


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import java.time.ZonedDateTime;
import java.util.UUID;

import static java.util.Objects.isNull;

@Data
@Builder
@AllArgsConstructor
Expand Down Expand Up @@ -90,9 +92,14 @@ public ResourceResponse convertToResponse() {
.onLeave(onLeave)
.resourceType(resourceType)
.startDate(startDate)
.endDate(endDate)
.endDate(shouldHideEndDateIfBeforeNow())
.stale(stale)
.links(Links.getFor(this))
.build();
}

private LocalDate shouldHideEndDateIfBeforeNow() {
if (isNull(this.endDate) || this.endDate.isBefore(LocalDate.now())) return null;
else return this.endDate;
}
}
Loading