From e60f01c2c132e25fe8221deff39c9ad479e427f4 Mon Sep 17 00:00:00 2001 From: Tom Winter Date: Mon, 11 Nov 2024 18:49:56 +0100 Subject: [PATCH] fix: use arg name depending on report version (#47) --- .../controller/ReportCalculationController.kt | 12 ++++++++++-- .../usecase/DefaultReportCalculationUseCase.kt | 2 -- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt index 52fe745..96ea315 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/controller/ReportCalculationController.kt @@ -67,11 +67,19 @@ class ReportCalculationController( val args = mutableMapOf() if (from != null) { - args["from"] = from.toInstant().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME) + if (report.version == 1) { + args["from"] = from.toInstant().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME) + } else { + args["startDate"] = from.toInstant().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME) + } } if (to != null) { - args["to"] = to.toInstant().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME) + if (report.version == 1) { + args["to"] = to.toInstant().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME) + } else { + args["endDate"] = to.toInstant().atOffset(ZoneOffset.UTC).format(DateTimeFormatter.ISO_DATE_TIME) + } } val createReportCalculationResponse = createReportCalculationUseCase.createReportCalculation( diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/usecase/DefaultReportCalculationUseCase.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/usecase/DefaultReportCalculationUseCase.kt index 1b6d710..4cfe305 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/usecase/DefaultReportCalculationUseCase.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/usecase/DefaultReportCalculationUseCase.kt @@ -55,7 +55,6 @@ class DefaultReportCalculationUseCase( ) : ReportCalculationUseCase() { override fun apply(request: ReportCalculationRequest): UseCaseOutcome { - val reportCalculation: ReportCalculation = try { reportCalculationStorage.fetchReportCalculation( DomainReference(request.reportCalculationId) @@ -100,7 +99,6 @@ class DefaultReportCalculationUseCase( private fun handleSqlReport( report: Report, reportCalculation: ReportCalculation ): UseCaseOutcome { - for ((argKey: String, transformationKeys: List) in report.transformations) { handleTransformations(argKey, transformationKeys, reportCalculation.args) }