diff options
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/kotlin/dev/dnpm/etl/processor/web/StatisticsController.kt | 31 | ||||
| -rw-r--r-- | src/main/resources/templates/statistics.html | 32 |
2 files changed, 62 insertions, 1 deletions
diff --git a/src/main/kotlin/dev/dnpm/etl/processor/web/StatisticsController.kt b/src/main/kotlin/dev/dnpm/etl/processor/web/StatisticsController.kt index e48d5df..8dfe595 100644 --- a/src/main/kotlin/dev/dnpm/etl/processor/web/StatisticsController.kt +++ b/src/main/kotlin/dev/dnpm/etl/processor/web/StatisticsController.kt @@ -19,18 +19,47 @@ package dev.dnpm.etl.processor.web +import dev.dnpm.etl.processor.monitoring.RequestStatus +import dev.dnpm.etl.processor.monitoring.RequestType +import dev.dnpm.etl.processor.monitoring.SubmissionType +import dev.dnpm.etl.processor.services.RequestService +import net.sf.saxon.tree.tiny.Statistics import org.springframework.stereotype.Controller import org.springframework.ui.Model import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.RequestMapping import java.time.Instant +import java.time.ZoneId +import java.time.format.DateTimeFormatter @Controller @RequestMapping(path = ["/statistics"]) -class StatisticsController { +class StatisticsController( + private val requestService: RequestService, +) { @GetMapping fun index(model: Model): String { + val submissions = + requestService + .findAll() + .asSequence() + .filter { it.type == RequestType.MTB_FILE } + .filter { listOf(RequestStatus.SUCCESS, RequestStatus.WARNING).contains(it.status) } + .sortedByDescending { it.processedAt } + .groupBy { + val formatter = DateTimeFormatter.ofPattern("yyyy-MM").withZone(ZoneId.systemDefault()) + formatter.format(it.processedAt) + }.map { + mapOf( + "month" to it.key, + "accepted" to it.value.count { it.submissionAccepted }, + "initial" to it.value.count { it.submissionType == SubmissionType.INITIAL }, + "submissions" to it.value.size, + ) + }.toList() + model.addAttribute("now", Instant.now()) + model.addAttribute("submissions", submissions) return "statistics" } } diff --git a/src/main/resources/templates/statistics.html b/src/main/resources/templates/statistics.html index 1da382c..231bfe9 100644 --- a/src/main/resources/templates/statistics.html +++ b/src/main/resources/templates/statistics.html @@ -14,6 +14,38 @@ </p> <section> + <h2>Submissions</h2> + <p> + Die übermittelten Meldungen sind nach Monaten absteigen sortiert. + </p> + <p> + Achtung: Die Anzahl der Meldebestätigungen und die Anzahl der initialen Meldungen + werden erst seit Version 0.15 erfasst. + </p> + <div class="border"> + <table> + <thead> + <tr> + <th>Monat</th> + <th>Mit Meldebestätigung</th> + <th>Initiale Meldungen</th> + <th>Meldungen Gesamt</th> + </tr> + </thead> + <tbody> + <tr th:each="submission : ${submissions}"> + <td th:text="${submission['month']}"></td> + <td th:text="${submission['accepted']}"></td> + <td th:text="${submission['initial']}"></td> + <td th:text="${submission['submissions']}"></td> + </tr> + </tbody> + </table> + </div> + </section> + + + <section> <h2>MTB-File-Anfragen</h2> <p> Anfragen zur Aktualisierung von Patientendaten durch Übermittlung eines MTB-Files. |
