diff --git a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/core/DefaultReportCalculator.kt b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/core/DefaultReportCalculator.kt index 4721f5c..522bc6a 100644 --- a/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/core/DefaultReportCalculator.kt +++ b/application/aam-backend-service/src/main/kotlin/com/aamdigital/aambackendservice/reporting/reportcalculation/core/DefaultReportCalculator.kt @@ -33,9 +33,7 @@ class DefaultReportCalculator( return@flatMap Mono.error(InvalidArgumentException()) } - if (reportCalculation.args["from"] == reportCalculation.args["to"]) { - reportCalculation.args.remove("to") - } + setToDateToLastMinuteOfDay(reportCalculation.args) val queryResult = queryStorage.executeQuery( query = QueryRequest( @@ -55,6 +53,11 @@ class DefaultReportCalculator( } } + private fun setToDateToLastMinuteOfDay(args: MutableMap) { + val toDateString = args["to"] ?: return + args["to"] = toDateString.substring(IntRange(0, 9)) + "T23:59:59.999Z" + } + private fun getReportCalculationArgs(neededArgs: List, givenArgs: Map): List = neededArgs .map { diff --git a/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/start-report-calculation.feature b/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/start-report-calculation.feature index e9122a5..01efab4 100644 --- a/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/start-report-calculation.feature +++ b/application/aam-backend-service/src/test/resources/cucumber/features/reporting/reportcalculation/start-report-calculation.feature @@ -57,3 +57,21 @@ Feature: the report calculation endpoint persist to database When the client calls GET /v1/reporting/report-calculation/ReportCalculation:2/data Then the client receives an json object Then the client receives status code of 200 + + Scenario: ReportCalculation with arguments is processed within 30 seconds + Given document ReportConfig:3 is stored in database app + Given document Config:CONFIG_ENTITY is stored in database app + Given document ReportCalculation:3 is stored in database report-calculation + Given signed in as client dummy-client with secret client-secret in realm dummy-realm + When the client calls GET /v1/reporting/report-calculation/ReportCalculation:3 + Then the client receives an json object + Then the client receives status code of 200 + Then the client receives value PENDING for property status + Then the client waits for 15000 milliseconds + When the client calls GET /v1/reporting/report-calculation/ReportCalculation:3 + Then the client receives an json object + Then the client receives status code of 200 + Then the client receives value FINISHED_SUCCESS for property status + When the client calls GET /v1/reporting/report-calculation/ReportCalculation:3/data + Then the client receives an json object + Then the client receives status code of 200 diff --git a/application/aam-backend-service/src/test/resources/database/documents/Config:CONFIG_ENTITY.json b/application/aam-backend-service/src/test/resources/database/documents/Config:CONFIG_ENTITY.json index 3f636e6..9327873 100644 --- a/application/aam-backend-service/src/test/resources/database/documents/Config:CONFIG_ENTITY.json +++ b/application/aam-backend-service/src/test/resources/database/documents/Config:CONFIG_ENTITY.json @@ -83,6 +83,10 @@ "dataType": "string", "label": "School Timing" }, + "date": { + "dataType": "data", + "label": "Create Date" + }, "remarks": { "dataType": "string", "label": "Remarks" diff --git a/application/aam-backend-service/src/test/resources/database/documents/ReportCalculation:3.json b/application/aam-backend-service/src/test/resources/database/documents/ReportCalculation:3.json new file mode 100644 index 0000000..f4cb5b9 --- /dev/null +++ b/application/aam-backend-service/src/test/resources/database/documents/ReportCalculation:3.json @@ -0,0 +1,13 @@ +{ + "_id": "ReportCalculation:3", + "report": { + "id": "ReportConfig:3" + }, + "args": { + "from": "2024-01-01T00:00:00Z", + "to": "2024-04-30T00:00:00Z" + }, + "status": "PENDING", + "startDate": null, + "endDate": null +} diff --git a/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:1.json b/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:1.json index 7853f26..6a58c4e 100644 --- a/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:1.json +++ b/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:1.json @@ -2,6 +2,6 @@ "_id": "ReportConfig:1", "title": "Test Report 1", "mode": "sql", - "aggregationDefinition": "SELECT s.name as name, s.privateSchool as privateSchool FROM School as s", - "args": [] + "neededArgs": [], + "aggregationDefinition": "SELECT s.name as name, s.privateSchool as privateSchool FROM School as s" } diff --git a/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:2.json b/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:2.json index b598fd1..2d02547 100644 --- a/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:2.json +++ b/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:2.json @@ -2,6 +2,6 @@ "_id": "ReportConfig:2", "title": "Test Report 2", "mode": "sql", - "aggregationDefinition": "SELECT s.name as name, s.privateSchool as privateSchool FROM School as s", - "args": [] + "neededArgs": [], + "aggregationDefinition": "SELECT s.name as name, s.privateSchool as privateSchool FROM School as s" } diff --git a/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:3.json b/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:3.json new file mode 100644 index 0000000..baced96 --- /dev/null +++ b/application/aam-backend-service/src/test/resources/database/documents/ReportConfig:3.json @@ -0,0 +1,10 @@ +{ + "_id": "ReportConfig:3", + "title": "Test Report 3", + "mode": "sql", + "neededArgs": [ + "from", + "to" + ], + "aggregationDefinition": "SELECT s.name as name, s.privateSchool as privateSchool FROM School as s WHERE s.date BETWEEN ? AND ?" +}