mirror of
https://github.com/pcvolkmer/etl-processor.git
synced 2025-04-19 17:26:51 +00:00
Add delete requests to be shown in statistics page
This commit is contained in:
parent
4f7f5e4d89
commit
9c9760c3ec
@ -21,10 +21,12 @@ package dev.dnpm.etl.processor.web
|
|||||||
|
|
||||||
import dev.dnpm.etl.processor.monitoring.RequestRepository
|
import dev.dnpm.etl.processor.monitoring.RequestRepository
|
||||||
import dev.dnpm.etl.processor.monitoring.RequestStatus
|
import dev.dnpm.etl.processor.monitoring.RequestStatus
|
||||||
|
import dev.dnpm.etl.processor.monitoring.RequestType
|
||||||
import org.springframework.http.MediaType
|
import org.springframework.http.MediaType
|
||||||
import org.springframework.http.codec.ServerSentEvent
|
import org.springframework.http.codec.ServerSentEvent
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
import org.springframework.web.bind.annotation.GetMapping
|
||||||
import org.springframework.web.bind.annotation.RequestMapping
|
import org.springframework.web.bind.annotation.RequestMapping
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam
|
||||||
import org.springframework.web.bind.annotation.RestController
|
import org.springframework.web.bind.annotation.RestController
|
||||||
import reactor.core.publisher.Flux
|
import reactor.core.publisher.Flux
|
||||||
import reactor.core.publisher.Sinks
|
import reactor.core.publisher.Sinks
|
||||||
@ -41,8 +43,14 @@ class StatisticsRestController(
|
|||||||
) {
|
) {
|
||||||
|
|
||||||
@GetMapping(path = ["requeststates"])
|
@GetMapping(path = ["requeststates"])
|
||||||
fun requestStates(): List<NameValue> {
|
fun requestStates(@RequestParam(required = false, defaultValue = "false") delete: Boolean): List<NameValue> {
|
||||||
return requestRepository.countStates()
|
val states = if (delete) {
|
||||||
|
requestRepository.countDeleteStates()
|
||||||
|
} else {
|
||||||
|
requestRepository.countStates()
|
||||||
|
}
|
||||||
|
|
||||||
|
return states
|
||||||
.map {
|
.map {
|
||||||
val color = when (it.status) {
|
val color = when (it.status) {
|
||||||
RequestStatus.ERROR -> "red"
|
RequestStatus.ERROR -> "red"
|
||||||
@ -56,9 +64,21 @@ class StatisticsRestController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = ["requestslastmonth"])
|
@GetMapping(path = ["requestslastmonth"])
|
||||||
fun requestsLastMonth(): List<DateNameValues> {
|
fun requestsLastMonth(
|
||||||
|
@RequestParam(
|
||||||
|
required = false,
|
||||||
|
defaultValue = "false"
|
||||||
|
) delete: Boolean
|
||||||
|
): List<DateNameValues> {
|
||||||
|
val requestType = if (delete) {
|
||||||
|
RequestType.DELETE
|
||||||
|
} else {
|
||||||
|
RequestType.MTB_FILE
|
||||||
|
}
|
||||||
|
|
||||||
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("Europe/Berlin"))
|
val formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("Europe/Berlin"))
|
||||||
val data = requestRepository.findAll()
|
val data = requestRepository.findAll()
|
||||||
|
.filter { it.type == requestType }
|
||||||
.filter { it.processedAt.isAfter(Instant.now().minus(30, ChronoUnit.DAYS)) }
|
.filter { it.processedAt.isAfter(Instant.now().minus(30, ChronoUnit.DAYS)) }
|
||||||
.groupBy { formatter.format(it.processedAt) }
|
.groupBy { formatter.format(it.processedAt) }
|
||||||
.map {
|
.map {
|
||||||
@ -91,8 +111,14 @@ class StatisticsRestController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = ["requestpatientstates"])
|
@GetMapping(path = ["requestpatientstates"])
|
||||||
fun requestPatientStates(): List<NameValue> {
|
fun requestPatientStates(@RequestParam(required = false, defaultValue = "false") delete: Boolean): List<NameValue> {
|
||||||
return requestRepository.findPatientUniqueStates().map {
|
val states = if (delete) {
|
||||||
|
requestRepository.findPatientUniqueDeleteStates()
|
||||||
|
} else {
|
||||||
|
requestRepository.findPatientUniqueStates()
|
||||||
|
}
|
||||||
|
|
||||||
|
return states.map {
|
||||||
val color = when (it.status) {
|
val color = when (it.status) {
|
||||||
RequestStatus.ERROR -> "red"
|
RequestStatus.ERROR -> "red"
|
||||||
RequestStatus.WARNING -> "darkorange"
|
RequestStatus.WARNING -> "darkorange"
|
||||||
@ -109,13 +135,23 @@ class StatisticsRestController(
|
|||||||
Flux.fromIterable(
|
Flux.fromIterable(
|
||||||
listOf(
|
listOf(
|
||||||
ServerSentEvent.builder<Any>()
|
ServerSentEvent.builder<Any>()
|
||||||
.event("requeststates").id("none").data(this.requestStates())
|
.event("requeststates").id("none").data(this.requestStates(false))
|
||||||
.build(),
|
.build(),
|
||||||
ServerSentEvent.builder<Any>()
|
ServerSentEvent.builder<Any>()
|
||||||
.event("requestslastmonth").id("none").data(this.requestsLastMonth())
|
.event("requestslastmonth").id("none").data(this.requestsLastMonth(false))
|
||||||
.build(),
|
.build(),
|
||||||
ServerSentEvent.builder<Any>()
|
ServerSentEvent.builder<Any>()
|
||||||
.event("requestpatientstates").id("none").data(this.requestPatientStates())
|
.event("requestpatientstates").id("none").data(this.requestPatientStates(false))
|
||||||
|
.build(),
|
||||||
|
|
||||||
|
ServerSentEvent.builder<Any>()
|
||||||
|
.event("deleterequeststates").id("none").data(this.requestStates(true))
|
||||||
|
.build(),
|
||||||
|
ServerSentEvent.builder<Any>()
|
||||||
|
.event("deleterequestslastmonth").id("none").data(this.requestsLastMonth(true))
|
||||||
|
.build(),
|
||||||
|
ServerSentEvent.builder<Any>()
|
||||||
|
.event("deleterequestpatientstates").id("none").data(this.requestPatientStates(true))
|
||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -9,13 +9,30 @@
|
|||||||
<div th:replace="~{fragments.html :: nav}"></div>
|
<div th:replace="~{fragments.html :: nav}"></div>
|
||||||
<main>
|
<main>
|
||||||
<h1>Statistiken</h1>
|
<h1>Statistiken</h1>
|
||||||
|
<p>
|
||||||
|
Hier sehen Sie eine Übersicht über eingegangene Anfragen.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<h2>MTB-File-Anfragen</h2>
|
||||||
|
<p>
|
||||||
|
Anfragen zur Aktualisierung von Patientendaten durch Übermittlung eines MTB-Files.
|
||||||
|
</p>
|
||||||
<div>
|
<div>
|
||||||
<div id="piechart1" class="chart chart-50pc"></div>
|
<div id="piechart1" class="chart chart-50pc"></div>
|
||||||
<div id="piechart2" class="chart chart-50pc"></div>
|
<div id="piechart2" class="chart chart-50pc"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="barchart" class="chart"></div>
|
<div id="barchart" class="chart"></div>
|
||||||
|
|
||||||
|
<h2>Löschanfragen</h2>
|
||||||
|
<p>
|
||||||
|
Anfragen zur Löschung von Patientendaten, wenn kein Consent vorliegt.
|
||||||
|
</p>
|
||||||
|
<div>
|
||||||
|
<div id="piechartdel1" class="chart chart-50pc"></div>
|
||||||
|
<div id="piechartdel2" class="chart chart-50pc"></div>
|
||||||
|
</div>
|
||||||
|
<div id="barchartdel" class="chart"></div>
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
<script th:src="@{/echarts.min.js}"></script>
|
<script th:src="@{/echarts.min.js}"></script>
|
||||||
<script th:src="@{/scripts.js}"></script>
|
<script th:src="@{/scripts.js}"></script>
|
||||||
@ -25,6 +42,10 @@
|
|||||||
drawPieChart('statistics/requestpatientstates', 'piechart2', 'Statusverteilung nach Patient');
|
drawPieChart('statistics/requestpatientstates', 'piechart2', 'Statusverteilung nach Patient');
|
||||||
drawBarChart('statistics/requestslastmonth', 'barchart', 'Anfragen der letzten 30 Tage');
|
drawBarChart('statistics/requestslastmonth', 'barchart', 'Anfragen der letzten 30 Tage');
|
||||||
|
|
||||||
|
drawPieChart('statistics/requeststates?delete=true', 'piechartdel1', 'Statusverteilung aller Anfragen');
|
||||||
|
drawPieChart('statistics/requestpatientstates?delete=true', 'piechartdel2', 'Statusverteilung nach Patient');
|
||||||
|
drawBarChart('statistics/requestslastmonth?delete=true', 'barchartdel', 'Anfragen der letzten 30 Tage');
|
||||||
|
|
||||||
const eventSource = new EventSource('statistics/events');
|
const eventSource = new EventSource('statistics/events');
|
||||||
eventSource.addEventListener('requeststates', event => {
|
eventSource.addEventListener('requeststates', event => {
|
||||||
drawPieChart('statistics/requeststates', 'piechart1', 'Statusverteilung aller Anfragen', JSON.parse(event.data));
|
drawPieChart('statistics/requeststates', 'piechart1', 'Statusverteilung aller Anfragen', JSON.parse(event.data));
|
||||||
@ -35,6 +56,16 @@
|
|||||||
eventSource.addEventListener('requestslastmonth', event => {
|
eventSource.addEventListener('requestslastmonth', event => {
|
||||||
drawBarChart('statistics/requestslastmonth', 'barchart', 'Anfragen des letzten Monats', JSON.parse(event.data));
|
drawBarChart('statistics/requestslastmonth', 'barchart', 'Anfragen des letzten Monats', JSON.parse(event.data));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
eventSource.addEventListener('deleterequeststates', event => {
|
||||||
|
drawPieChart('statistics/requeststates?delete=true', 'piechartdel1', 'Statusverteilung aller Anfragen', JSON.parse(event.data));
|
||||||
|
});
|
||||||
|
eventSource.addEventListener('deleterequestpatientstates', event => {
|
||||||
|
drawPieChart('statistics/requestpatientstates?delete=true', 'piechartdel2', 'Statusverteilung nach Patient', JSON.parse(event.data));
|
||||||
|
});
|
||||||
|
eventSource.addEventListener('deleterequestslastmonth', event => {
|
||||||
|
drawBarChart('statistics/requestslastmonth?delete=true', 'barchartdel', 'Anfragen des letzten Monats', JSON.parse(event.data));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user