Skip to content

Commit

Permalink
Changed report generation to a POST so that member ids could be part …
Browse files Browse the repository at this point in the history
…of the body instead of a URL parameter.
  • Loading branch information
ocielliottc committed Dec 17, 2024
1 parent 5a76dd4 commit b5e4977
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.micronaut.http.MediaType;
import io.micronaut.http.HttpStatus;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Body;
import io.micronaut.http.annotation.Post;
import io.micronaut.http.annotation.Get;
import io.micronaut.http.multipart.CompletedFileUpload;
Expand All @@ -30,6 +31,7 @@
import reactor.core.publisher.Flux;
import reactor.core.scheduler.Schedulers;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.Valid;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -121,10 +123,9 @@ private String uploadHelper(ReportDataServices.DataType dataType,
}
}

@Get(uri="/generate")
@Post(uri="/generate")
@RequiredPermission(Permission.CAN_CREATE_MERIT_REPORT)
public HttpStatus generate(@NotNull List<UUID> memberIds,
@NotNull UUID reviewPeriodId) {
public HttpStatus generate(@Body @Valid ReportDataDTO dto) {
MarkdownGeneration markdown =
new MarkdownGeneration(reportDataServices,
kudosRepository,
Expand All @@ -137,7 +138,7 @@ public HttpStatus generate(@NotNull List<UUID> memberIds,
templateQuestionServices,
employeeHoursServices,
fileServices);
markdown.upload(memberIds, reviewPeriodId);
markdown.upload(dto.getMemberIds(), dto.getReviewPeriodId());
return HttpStatus.OK;
}
}
Original file line number Diff line number Diff line change
@@ -1,58 +1,20 @@
package com.objectcomputing.checkins.services.reports;

import com.objectcomputing.checkins.services.memberprofile.MemberProfile;
import io.micronaut.core.annotation.Introspected;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDate;
import java.util.List;
import java.util.UUID;

@Getter
@Setter
@AllArgsConstructor
@Introspected
public class ReportDataDTO {

@NotNull
private UUID memberId;
private List<UUID> memberIds;

@NotNull
private UUID reviewPeriodId;

@NotNull
private LocalDate startDate;

@NotNull
private LocalDate endDate;

@NotNull
private MemberProfile memberProfile;

@NotNull
private List<ReportKudos> kudos;

@NotNull
private List<CompensationHistory.Compensation> compensationHistory;

@NotNull
private CurrentInformation.Information currentInformation;

@NotNull
private List<PositionHistory.Position> positionHistory;

@NotNull
private List<Feedback> selfReviews;

@NotNull
private List<Feedback> reviews;

@NotNull
private List<Feedback> feedback;

@NotNull
private ReportHours hours;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import org.junit.jupiter.api.Test;

import java.io.File;
import java.util.UUID;
import java.util.ArrayList;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

Expand Down Expand Up @@ -116,10 +118,12 @@ void processReportData() {
final String response = client.toBlocking().retrieve(request);
assertNotNull(response);

request = HttpRequest.GET(
String.format("/generate?memberIds=%s&reviewPeriodId=%s",
target.getId(),
reviewPeriod.getId().toString()))
ReportDataDTO dto = new ReportDataDTO();
ArrayList<UUID> memberIds = new ArrayList<>();
memberIds.add(target.getId());
dto.setReviewPeriodId(reviewPeriod.getId());
dto.setMemberIds(memberIds);
request = HttpRequest.POST("/generate", dto)
.basicAuth(admin.getWorkEmail(), ADMIN_ROLE);
client.toBlocking().exchange(request);

Expand All @@ -129,10 +133,12 @@ void processReportData() {

@Test
void processReportDataWithoutPermission() {
final HttpRequest<?> request = HttpRequest.GET(
String.format("/generate?memberIds=%s&reviewPeriodId=%s",
regular.getId(),
reviewPeriod.getId()))
ReportDataDTO dto = new ReportDataDTO();
ArrayList<UUID> memberIds = new ArrayList<>();
memberIds.add(regular.getId());
dto.setReviewPeriodId(reviewPeriod.getId());
dto.setMemberIds(memberIds);
final HttpRequest<?> request = HttpRequest.POST("/generate", dto)
.basicAuth(regular.getWorkEmail(), MEMBER_ROLE);
HttpClientResponseException responseException =
assertThrows(HttpClientResponseException.class,
Expand Down
7 changes: 4 additions & 3 deletions web-ui/src/api/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@ export const downloadData = (url, cookie, params) => {

export const initiate = (url, cookie, params) => {
return resolve({
method: 'GET',
params: params,
method: 'POST',
headers: {
'X-CSRF-Header': cookie,
Accept: 'application/json',
'Content-Type': 'application/json;charset=UTF-8'
},
url: url
url: url,
data: params,
});
};

0 comments on commit b5e4977

Please sign in to comment.