diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt index f919c1c..f0599a1 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Api.kt @@ -48,4 +48,18 @@ data class ChartDataset( val lineTension: Double = 0.1 ) { constructor(label: String, color: String, data: List) : this(label, color, color, data) -} \ No newline at end of file +} + +data class AfiPieChart( + val labels: List = listOf("Monitoring", "Knowledge", "Control", "Conservatism", "Teamwork"), + val datasets: List +) { + constructor(afiPieChartDataset: AfiPieChartDataset) : this(datasets = listOf(afiPieChartDataset)) +} + +data class AfiPieChartDataset( + val data: List, + val backgroundColor: List = listOf("#F90", "#000", "#00FF00", "#33F", "#FF0") +) { + constructor(monitoring: Int, knowledge: Int, control: Int, conservatism: Int, teamwork: Int) : this(data = listOf(monitoring, knowledge, control, conservatism, teamwork)) +} diff --git a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt index 8936894..8bd1f42 100644 --- a/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt +++ b/backend/src/main/kotlin/uk/co/neviyn/observationdatabase/Controller.kt @@ -190,6 +190,39 @@ class Controller { } return builder.toString() } + + val afiPieThreshold = 3 + + @PostMapping("/observations/afipie") + fun getObservationsAfiPieChartData(@Valid @RequestBody observationsRequest: ObservationsRequest): AfiPieChart? { + val data = getObservations(observationsRequest) + var monitoring = 0 + var knowledge = 0 + var control = 0 + var conservatism = 0 + var teamwork = 0 + for (x in data) { + for (y in x.scenarios) { + if (y.monitoring.rating <= afiPieThreshold) + monitoring++ + if (y.knowledge.rating <= afiPieThreshold) + knowledge++ + if (y.control.rating <= afiPieThreshold) + control++ + if (y.controlProcedural.rating <= afiPieThreshold) + control++ + if (y.conservatism.rating <= afiPieThreshold) + conservatism++ + if (y.teamworkCommunications.rating <= afiPieThreshold) + teamwork++ + if (y.teamworkLeadership.rating <= afiPieThreshold) + teamwork++ + if (y.teamworkWorkload.rating <= afiPieThreshold) + teamwork++ + } + } + return AfiPieChart(AfiPieChartDataset(monitoring, knowledge, control, conservatism, teamwork)) + } } data class AverageData( diff --git a/frontend/src/components/AfiPie.vue b/frontend/src/components/AfiPie.vue new file mode 100644 index 0000000..16e33b1 --- /dev/null +++ b/frontend/src/components/AfiPie.vue @@ -0,0 +1,12 @@ + diff --git a/frontend/src/views/Stats.vue b/frontend/src/views/Stats.vue index 9c957cf..cf4a962 100644 --- a/frontend/src/views/Stats.vue +++ b/frontend/src/views/Stats.vue @@ -13,6 +13,10 @@ + + Trends + AFIs + @@ -49,22 +53,31 @@ Refresh - - + + - - -

No data found with the given search parameters.

+ +
+ + Loading... + + + + +

No data found with the given search parameters.

+
+