Skip to content

Commit

Permalink
fix: dont nest report v1 data in array (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwwinter authored Nov 7, 2024
1 parent c4aa04d commit de169dc
Showing 1 changed file with 25 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,18 @@ class DefaultReportCalculationUseCase(

try {
reportCalculationStorage.storeCalculation(
reportCalculation = reportCalculation
.setStatus(ReportCalculationStatus.RUNNING)
.setStartDate(
startDate = getIsoLocalDateTime()
)
reportCalculation = reportCalculation.setStatus(ReportCalculationStatus.RUNNING).setStartDate(
startDate = getIsoLocalDateTime()
)
)

handleSqlReport(report, reportCalculation)
markCalculationAsSuccess(request)
} catch (ex: Exception) {
reportCalculationStorage.storeCalculation(
reportCalculation = reportCalculation
.setStatus(ReportCalculationStatus.FINISHED_ERROR)
.setEndDate(
endDate = getIsoLocalDateTime()
)
.setErrorDetails(ex.localizedMessage)
reportCalculation = reportCalculation.setStatus(ReportCalculationStatus.FINISHED_ERROR).setEndDate(
endDate = getIsoLocalDateTime()
).setErrorDetails(ex.localizedMessage)
)

return handleException(ex)
Expand All @@ -103,29 +98,32 @@ class DefaultReportCalculationUseCase(

@Throws(AamException::class)
private fun handleSqlReport(
report: Report,
reportCalculation: ReportCalculation
report: Report, reportCalculation: ReportCalculation
): UseCaseOutcome<ReportCalculationData> {

for ((argKey: String, transformationKeys: List<String>) in report.transformations) {
handleTransformations(argKey, transformationKeys, reportCalculation.args)
}

val result = reportCalculationStorage.addReportCalculationData(
reportCalculation = reportCalculation,
file = SequenceInputStream(
Collections.enumeration(
listOf(
"[".byteInputStream(),
handleReportItems(
queries = report.items,
report = report,
reportCalculation = reportCalculation
),
"]".byteInputStream()
)
val resultData = if (report.version == 1) {
listOf(
handleReportItems(
queries = report.items, report = report, reportCalculation = reportCalculation
),
)
} else {
listOf(
"[".byteInputStream(),
handleReportItems(
queries = report.items, report = report, reportCalculation = reportCalculation
),
"]".byteInputStream()
)
}

)
val result = reportCalculationStorage.addReportCalculationData(
reportCalculation = reportCalculation, file = SequenceInputStream(
Collections.enumeration(resultData)
)
)

Expand Down

0 comments on commit de169dc

Please sign in to comment.