|
1 | 1 | package fr.insee.genesis.controller.rest.responses; |
2 | 2 |
|
3 | 3 | import fr.insee.genesis.controller.dto.rawdata.LunaticJsonRawDataUnprocessedDto; |
| 4 | +import fr.insee.genesis.controller.utils.DateTimeUtils; |
4 | 5 | import fr.insee.genesis.domain.model.surveyunit.Mode; |
5 | 6 | import fr.insee.genesis.domain.model.surveyunit.rawdata.DataProcessResult; |
6 | 7 | import fr.insee.genesis.domain.model.surveyunit.rawdata.LunaticJsonRawDataModel; |
|
14 | 15 | import fr.insee.modelefiliere.RawResponseDto; |
15 | 16 | import io.swagger.v3.oas.annotations.Operation; |
16 | 17 | import io.swagger.v3.oas.annotations.Parameter; |
| 18 | +import io.swagger.v3.oas.annotations.media.Schema; |
17 | 19 | import jakarta.validation.Valid; |
18 | 20 | import lombok.RequiredArgsConstructor; |
19 | 21 | import lombok.extern.slf4j.Slf4j; |
@@ -199,15 +201,44 @@ public ResponseEntity<Map<String, List<String>>> getProcessedDataIdsSinceHours( |
199 | 201 | @PreAuthorize("hasRole('USER_BATCH_GENERIC')") |
200 | 202 | public ResponseEntity<PagedModel<LunaticJsonRawDataModel>> getLunaticJsonRawDataModelFromJsonBody( |
201 | 203 | @PathVariable String campaignId, |
202 | | - @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant startDate, |
203 | | - @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant endDate, |
| 204 | + @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 205 | + @Parameter(description = "Start date in UTC", example = "2026-02-02T00:00:00Z") |
| 206 | + Instant startDate, |
| 207 | + @RequestParam(value = "localStartDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 208 | + @Parameter(description = "Extract since in Europe/Paris timezone", schema = @Schema(type = "string", format = "date-time", example = "2026-02-02T01:00:00")) |
| 209 | + LocalDateTime localStartDate, |
| 210 | + @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 211 | + @Parameter(description = "End date in UTC", example = "2026-02-02T00:00:00Z") |
| 212 | + Instant endDate, |
| 213 | + @RequestParam(value = "localEndDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 214 | + @Parameter(description = "Extract until in Europe/Paris timezone", schema = @Schema(type = "string", format = "date-time", example = "2026-02-02T01:00:00")) |
| 215 | + LocalDateTime localEndDate, |
204 | 216 | @RequestParam(value = "page", defaultValue = "0") int page, |
205 | 217 | @RequestParam(value = "size", defaultValue = "1000") int size |
206 | 218 | ) { |
207 | | - log.info("Try to read raw JSONs for campaign {}, with startDate={} and endDate={} - page={} - size={}", campaignId, startDate, endDate,page,size); |
| 219 | + Instant resolvedStartDate = DateTimeUtils.resolveInstant(startDate, localStartDate); |
| 220 | + Instant resolvedEndDate = DateTimeUtils.resolveInstant(endDate, localEndDate); |
| 221 | + log.info( |
| 222 | + "Try to read raw JSONs for campaign {} with startDateUtc={} startDateLocal={} endDateUtc={} endDateLocal={} - page={} - size={}", |
| 223 | + campaignId, |
| 224 | + resolvedStartDate, |
| 225 | + DateTimeUtils.toFranceDateTime(resolvedStartDate), |
| 226 | + resolvedEndDate, |
| 227 | + DateTimeUtils.toFranceDateTime(resolvedEndDate), |
| 228 | + page, |
| 229 | + size |
| 230 | + ); |
208 | 231 | Pageable pageable = PageRequest.of(page, size); |
209 | | - Page<LunaticJsonRawDataModel> rawResponses = lunaticJsonRawDataApiPort.findRawDataByCampaignIdAndDate(campaignId, startDate, endDate, pageable); |
210 | | - log.info("rawResponses, lunatic-json for campaign {}, with startDate={} and endDate={} ={}", campaignId, startDate, endDate,rawResponses.getContent().size()); |
| 232 | + Page<LunaticJsonRawDataModel> rawResponses = lunaticJsonRawDataApiPort.findRawDataByCampaignIdAndDate(campaignId, resolvedStartDate, resolvedEndDate, pageable); |
| 233 | + log.info( |
| 234 | + "rawResponses, lunatic-json for campaign {} with startDateUtc={} startDateLocal={} endDateUtc={} endDateLocal={} count={}", |
| 235 | + campaignId, |
| 236 | + resolvedStartDate, |
| 237 | + DateTimeUtils.toFranceDateTime(resolvedStartDate), |
| 238 | + resolvedEndDate, |
| 239 | + DateTimeUtils.toFranceDateTime(resolvedEndDate), |
| 240 | + rawResponses.getContent().size() |
| 241 | + ); |
211 | 242 | return ResponseEntity.status(HttpStatus.OK).body(new PagedModel<>(rawResponses)); |
212 | 243 | } |
213 | 244 |
|
@@ -256,15 +287,41 @@ public ResponseEntity<Void> existsLunaticJsonByInterrogationId(@PathVariable Str |
256 | 287 | @PreAuthorize("hasRole('USER_BATCH_GENERIC')") |
257 | 288 | public ResponseEntity<PagedModel<RawResponseModel>> getRawResponsesFromJsonBody( |
258 | 289 | @PathVariable String campaignId, |
259 | | - @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant startDate, |
260 | | - @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Instant endDate, |
| 290 | + @RequestParam(value = "startDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 291 | + @Parameter(description = "Start date in UTC", example = "2026-02-02T00:00:00Z") |
| 292 | + Instant startDate, |
| 293 | + @RequestParam(value = "localStartDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 294 | + @Parameter(description = "Extract since in Europe/Paris timezone", schema = @Schema(type = "string", format = "date-time", example = "2026-02-02T01:00:00")) |
| 295 | + LocalDateTime localStartDate, |
| 296 | + @RequestParam(value = "endDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 297 | + @Parameter(description = "End date in UTC", example = "2026-04-02T00:00:00Z") |
| 298 | + Instant endDate, |
| 299 | + @RequestParam(value = "localEndDate", required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) |
| 300 | + @Parameter(description = "Extract until in Europe/Paris timezone", schema = @Schema(type = "string", format = "date-time", example = "2026-02-02T01:00:00")) |
| 301 | + LocalDateTime localEndDate, |
261 | 302 | @RequestParam(value = "page", defaultValue = "0") int page, |
262 | 303 | @RequestParam(value = "size", defaultValue = "1000") int size |
263 | 304 | ) { |
264 | | - log.info("Try to read raw lunatic JSONs for campaign {}, with startDate={} and endDate={} - page={} - size={}", campaignId, startDate, endDate,page,size); |
| 305 | + Instant resolvedStartDate = DateTimeUtils.resolveInstant(startDate, localStartDate); |
| 306 | + Instant resolvedEndDate = DateTimeUtils.resolveInstant(endDate, localEndDate); |
| 307 | + log.info("Try to read raw JSONs for campaign {} with startDateUtc={} startDateLocal={} endDateUtc={} endDateLocal={} - page={} - size={}", |
| 308 | + campaignId, |
| 309 | + resolvedStartDate, |
| 310 | + DateTimeUtils.toFranceDateTime(resolvedStartDate), |
| 311 | + resolvedEndDate, |
| 312 | + DateTimeUtils.toFranceDateTime(resolvedEndDate), |
| 313 | + page, |
| 314 | + size |
| 315 | + ); |
265 | 316 | Pageable pageable = PageRequest.of(page, size); |
266 | | - Page<RawResponseModel> rawResponses = rawResponseApiPort.findRawResponseDataByCampaignIdAndDate(campaignId, startDate, endDate, pageable); |
267 | | - log.info("rawResponses for campaign {}, with startDate={} and endDate={} ={}",campaignId, startDate, endDate, rawResponses.getContent().size()); |
| 317 | + Page<RawResponseModel> rawResponses = rawResponseApiPort.findRawResponseDataByCampaignIdAndDate(campaignId, resolvedStartDate, resolvedEndDate, pageable); |
| 318 | + log.info("rawResponses for campaign {},with startDateUtc={} startDateLocal={} endDateUtc={} endDateLocal={} count={}", |
| 319 | + campaignId, |
| 320 | + resolvedStartDate, |
| 321 | + DateTimeUtils.toFranceDateTime(resolvedStartDate), |
| 322 | + resolvedEndDate, |
| 323 | + DateTimeUtils.toFranceDateTime(resolvedEndDate), |
| 324 | + rawResponses.getContent().size()); |
268 | 325 | return ResponseEntity.status(HttpStatus.OK).body(new PagedModel<>(rawResponses)); |
269 | 326 | } |
270 | 327 |
|
|
0 commit comments