Skip to content

Commit

Permalink
NOD-682 request dates fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andrea-barchi committed Feb 2, 2024
1 parent 5cb31cc commit 6c030ca
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ public class OrgResource implements Serializable {
public Response getRevisions(
@PathParam("organizationId") @NotNull String organizationId,
@PathParam("fdr") @NotNull String fdr,
@NotNull @QueryParam("dateFrom") LocalDate dateFrom,
@NotNull @QueryParam("dateTo") LocalDate dateTo) {
@QueryParam("dateFrom") LocalDate dateFrom,
@QueryParam("dateTo") LocalDate dateTo) {

return Response.ok(workerService.getRevisions(organizationId, fdr, dateFrom, dateTo)).build();
}
Expand Down Expand Up @@ -106,9 +106,9 @@ public Response getFlow(
@PathParam("fdr") @NotNull String fdr,
@PathParam("psp") @NotNull String psp,
@PathParam("revision") @NotNull String revision,
@NotNull @QueryParam("dateFrom") LocalDate dateFrom,
@NotNull @QueryParam("dateTo") LocalDate dateTo,
@NotNull @QueryParam("fileType") String fileType) {
@QueryParam("dateFrom") LocalDate dateFrom,
@QueryParam("dateTo") LocalDate dateTo,
@QueryParam("fileType") String fileType) {
return Response.ok(
workerService.getFlow(organizationId, psp, fdr, revision, dateFrom, dateTo, fileType))
.build();
Expand All @@ -120,7 +120,7 @@ public Response getFlow(
public Response getDownloads(
@PathParam("organizationId") @NotNull String organizationId,
@PathParam("psp") @NotNull String psp,
@NotNull @QueryParam("date") LocalDate date) {
@QueryParam("date") LocalDate date) {
FrResponse fdrActions =
workerService.getFdrActions(
psp,
Expand All @@ -144,7 +144,7 @@ public Response getDownloads(
public Response getUploads(
@PathParam("organizationId") @NotNull String organizationId,
@PathParam("psp") @NotNull String psp,
@NotNull @QueryParam("date") LocalDate date) {
@QueryParam("date") LocalDate date) {
return Response.ok(
workerService.getFdrActions(
psp,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public class PspResource implements Serializable {
// https://pagopa.atlassian.net/wiki/spaces/PN5/pages/761201348/Design+Review+FdR+API+Assistenza#API-1---Get-all-FdR-by-PSP-%5BFR_01_04%5D
public Response frO1(
@PathParam("pspId") @NotNull String pspId,
@NotNull @QueryParam("dateFrom") LocalDate dateFrom,
@NotNull @QueryParam("dateTo") LocalDate dateTo,
@QueryParam("dateFrom") LocalDate dateFrom,
@QueryParam("dateTo") LocalDate dateTo,
@QueryParam("fdr") Optional<String> fdr,
@QueryParam("organizationId") Optional<String> organizationId) {
return Response.ok(
Expand Down Expand Up @@ -112,8 +112,8 @@ public Response frO1(
public Response frO2(
@PathParam("pspId") @NotNull String pspId,
@PathParam("iuv") @NotNull String iuv,
@NotNull @QueryParam("dateFrom") LocalDate dateFrom,
@NotNull @QueryParam("dateTo") LocalDate dateTo) {
@QueryParam("dateFrom") LocalDate dateFrom,
@QueryParam("dateTo") LocalDate dateTo) {
return Response.ok(workerService.getFdrByPspAndIuv(pspId, iuv, dateFrom, dateTo)).build();
}

Expand Down Expand Up @@ -154,8 +154,8 @@ public Response frO2(
public Response frO3(
@PathParam("pspId") @NotNull String pspId,
@PathParam("iur") @NotNull String iur,
@NotNull @QueryParam("dateFrom") LocalDate dateFrom,
@NotNull @QueryParam("dateTo") LocalDate dateTo) {
@QueryParam("dateFrom") LocalDate dateFrom,
@QueryParam("dateTo") LocalDate dateTo) {
return Response.ok(workerService.getFdrByPspAndIur(pspId, iur, dateFrom, dateTo)).build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ private DateRequest verifyDate(LocalDate dateFrom, LocalDate dateTo) {
dateTo = LocalDate.now();
dateFrom = dateTo.minusDays(dateRangeLimit);
}
if (ChronoUnit.DAYS.between(dateFrom, dateTo) > dateRangeLimit - 1) {
if (ChronoUnit.DAYS.between(dateFrom, dateTo) > dateRangeLimit) {
throw new AppException(AppErrorCodeMessageEnum.INTERVAL_TOO_LARGE, dateRangeLimit);
}
return DateRequest.builder().from(dateFrom).to(dateTo).build();
Expand Down Expand Up @@ -305,7 +305,11 @@ public FrResponse getRevisions(
creation -> fdrs.getRevisions().add(new RevisionInfo("NA", creation.getCreated())));
}

return FrResponse.builder().dateFrom(dateFrom).dateTo(dateTo).data(List.of(fdrs)).build();
return FrResponse.builder()
.dateFrom(dateRequest.getFrom())
.dateTo(dateRequest.getTo())
.data(List.of(fdrs))
.build();
}

public FdrFullInfoResponse getFlow(
Expand All @@ -317,18 +321,23 @@ public FdrFullInfoResponse getFlow(
LocalDate dateTo,
String fileType) {
DateRequest dateRequest = verifyDate(dateFrom, dateTo);
fileType = (fileType == null || fileType.isBlank()) ? "json" : fileType;
if (fileType.equalsIgnoreCase("json")) {
log.infof("Querying history table storage");
String flow =
fdrHistoryTableRepository.getBlobByNameAndRevision(dateRequest, flowName, revision);
log.infof("Done querying history table storage");
return FdrFullInfoResponse.builder().dateFrom(dateFrom).dateTo(dateTo).data(flow).build();
return FdrFullInfoResponse.builder()
.dateFrom(dateRequest.getFrom())
.dateTo(dateRequest.getTo())
.data(flow)
.build();
} else if (fileType.equalsIgnoreCase("xml")) {
GetXmlRendicontazioneResponse getXmlRendicontazioneResponse =
fdrOldRestClient.nodoChiediFlussoRendicontazione(organizationId, flowName);
return FdrFullInfoResponse.builder()
.dateFrom(dateFrom)
.dateTo(dateTo)
.dateFrom(dateRequest.getFrom())
.dateTo(dateRequest.getTo())
.data(getXmlRendicontazioneResponse.getXmlRendicontazione())
.build();
} else {
Expand Down

0 comments on commit 6c030ca

Please sign in to comment.