diff --git a/application/src/app.rs b/application/src/app.rs
index 63831ad..71677c9 100644
--- a/application/src/app.rs
+++ b/application/src/app.rs
@@ -1,3 +1,4 @@
+#![feature(diagnostic_namespace)]
use crate::error_template::{AppError, ErrorTemplate};
use leptos::*;
use leptos_meta::*;
diff --git a/application/src/main.rs b/application/src/main.rs
index abad6ce..07254b9 100644
--- a/application/src/main.rs
+++ b/application/src/main.rs
@@ -1,3 +1,4 @@
+#![feature(diagnostic_namespace)]
#[cfg(feature = "ssr")]
#[tokio::main]
async fn main() {
diff --git a/application/src/pages/groups.rs b/application/src/pages/groups.rs
index 58d33b3..b8d674f 100644
--- a/application/src/pages/groups.rs
+++ b/application/src/pages/groups.rs
@@ -1,5 +1,6 @@
-use crate::components;
+use crate::components::{self, participant};
use crate::util::surrealdb::schemas;
+use futures::stream::ForEach;
use leptos::*;
/// Renders the home page of your application.
@@ -22,6 +23,7 @@ pub fn Groups() -> impl IntoView {
let (participants_lifesaver, participants_hindernis, participants_popduiken) =
sort_by_events(participants_filtered);
+ let total_score_participants = sort_by_total_score(participants_filtered);
view! {
"Groups"
@@ -43,7 +45,7 @@ pub fn Groups() -> impl IntoView {
"Algemene score"
-
+
"Lifesaver"
@@ -61,6 +63,71 @@ pub fn Groups() -> impl IntoView {
}
}
+fn sort_by_total_score(
+ participants_filtered: Memo>,
+) -> Memo> {
+ let total_score_participants: Memo> = create_memo(move |_| {
+ let mut all_participants: Vec<(usize, schemas::ParticipantSignal)> = participants_filtered
+ .get()
+ .into_iter()
+ .enumerate()
+ .collect();
+
+ let mut lifesaver_best = 6_000_000;
+ let mut popduiken_best = 6_000_000;
+ let mut hindernis_best = 6_000_000;
+
+ for val in all_participants.clone().into_iter() {
+ if val.1.value.get().events == None {
+ continue;
+ }
+ let person = val.1.value.get().events.unwrap();
+ let person_lifesaver = person.lifesaver.unwrap_or(6_000_000);
+ let person_popduiken = person.popduiken.unwrap_or(6_000_000);
+ let person_hindernis = person.hindernis.unwrap_or(6_000_000);
+
+ if person_lifesaver < lifesaver_best {
+ lifesaver_best = person_lifesaver;
+ }
+ if person_popduiken < popduiken_best {
+ popduiken_best = person_popduiken;
+ }
+ if person_hindernis < hindernis_best {
+ hindernis_best = person_hindernis;
+ }
+ }
+
+ all_participants.sort_by(|(_, a), (_, b)| {
+ let part_a = match a.value.get().events {
+ Some(events) => {
+ (((events.lifesaver.unwrap_or(6_000_000) * 100) / lifesaver_best)
+ + ((events.hindernis.unwrap_or(6_000_000) * 100) / hindernis_best)
+ + ((events.popduiken.unwrap_or(6_000_000) * 100) / popduiken_best))
+ / 3
+ }
+ None => 36_000_000,
+ };
+ let part_b = match b.value.get().events {
+ Some(events) => {
+ (((events.lifesaver.unwrap_or(6_000_000) * 100) / lifesaver_best)
+ + ((events.hindernis.unwrap_or(6_000_000) * 100) / hindernis_best)
+ + ((events.popduiken.unwrap_or(6_000_000) * 100) / popduiken_best))
+ / 3
+ }
+ None => 36_000_000,
+ };
+
+ part_a.cmp(&part_b)
+ });
+
+ all_participants
+ .into_iter()
+ .map(|(_, value)| value)
+ .collect()
+ });
+ total_score_participants
+}
+
fn sort_by_events(
participants_filtered: Memo>,
) -> (