diff --git a/auth/Cargo.toml b/auth/Cargo.toml index 08397dc..ca797cf 100644 --- a/auth/Cargo.toml +++ b/auth/Cargo.toml @@ -3,7 +3,11 @@ name = "auth" version = "0.1.0" edition = "2021" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[profile.release] +codegen-units = 1 +lto = "fat" +strip = true +panic = "abort" [dependencies] actix-web = "4.3.0" diff --git a/backend/Dockerfile b/backend/Dockerfile index 96bc50e..274a6ea 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -60,7 +60,7 @@ COPY --from=public /usr/src/public/dist ./public COPY --from=templates-html /usr/src/templates/html ./templates/html COPY ./src ./src RUN if [ "${BUILD_ENV}" = "development" ]; then \ - make dev; \ + make dev && \ ldd bin/backend | tr -s '[:blank:]' '\n' | grep '^/' | \ xargs -I % sh -c 'mkdir -p $(dirname deps%); cp % deps%;'; \ else \ diff --git a/backend/src/backend/api/schema/mutation.cr b/backend/src/backend/api/schema/mutation.cr index caa62c4..c8e040a 100644 --- a/backend/src/backend/api/schema/mutation.cr +++ b/backend/src/backend/api/schema/mutation.cr @@ -193,7 +193,6 @@ module Backend # teacher_role_count = Db::User.query.where(role: Db::UserRole::Teacher).count # raise Errors::TeachersNotRegistered.new if teacher_role_count != Db::Teacher.query.count || teacher_role_count.zero? - pp! config = Db::Config.query.select(:can_vote).where { active }.first! raise Errors::VotingNotAllowed.new unless Db::Config.query.select(:can_vote).where { active }.first!.can_vote input.teacher_ids.each do |id| diff --git a/backend/src/backend/worker/jobs/assignment_job.cr b/backend/src/backend/worker/jobs/assignment_job.cr index f47117f..c3f100e 100644 --- a/backend/src/backend/worker/jobs/assignment_job.cr +++ b/backend/src/backend/worker/jobs/assignment_job.cr @@ -94,7 +94,8 @@ module Backend best : {assignment: Hash(Int32, Assignment), priority_score: Int64, teacher_score: Int64}? = nil empty_assignment_count = Hash.zip(teachers.map(&.id), [0] * teachers.size) p! "Starting assignment" - Backend.config.assignment_possibility_count.times.each do + i = 0 + while i < Backend.config.assignment_possibility_count assignment = {} of Int32 => Assignment assignment_count = empty_assignment_count.clone votes_a.shuffle(Random::Secure).each do |s, tvs| @@ -112,6 +113,8 @@ module Backend end end + next if assignment.size != student_count + priority_score = 0_i64 assignment.each do |_, a| priority_score += a[:priority] ** 2 @@ -146,7 +149,7 @@ module Backend active: true, priority_score: best.not_nil![:priority_score], teacher_score: best.not_nil![:teacher_score], - }) + }).id Db::StudentAssignment.import( best.not_nil![:assignment].map do |s, a| Db::StudentAssignment.new({ diff --git a/docker-compose.yml b/docker-compose.yml index ae6d813..4ea42c6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -90,6 +90,7 @@ services: BACKEND_AUTH_URL: "http://auth/v1" volumes: - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro - ./data/static:/static frontend: diff --git a/frontend/src/routes/home/student_vote.rs b/frontend/src/routes/home/student_vote.rs index 7c679c4..e5df458 100644 --- a/frontend/src/routes/home/student_vote.rs +++ b/frontend/src/routes/home/student_vote.rs @@ -138,6 +138,7 @@ impl Component for StudentVote { self.fetching = false; self.errors = errors; self.teachers = teachers; + true } Msg::RadioSelect { priority, teacher } => { @@ -168,8 +169,6 @@ impl Component for StudentVote { ) .await .unwrap(); - // log::debug!("{:?}", response.data.unwrap().create_vote.unwrap()); - log::debug!("{:?}", response); Msg::Vote(graphql::convert(response.errors)) }); @@ -239,37 +238,40 @@ impl Component for StudentVote { html! { <> -
+
{ format!("{}. Wahl", i + 1) } +
+ { + for self.teachers.iter().enumerate().filter_map(|(j, t)| { + let checked = curr_t == Some(&Some(t.id)); - { - for self.teachers.iter().enumerate().filter_map(|(j, t)| { - let checked = curr_t == Some(&Some(t.id)); + if teachers.contains(&t.id) && !checked { + None + } else { + let id = format!("{}_{}", name, j); + let teacher_id = t.id; + let onchange = ctx.link().callback(move |_| Msg::RadioSelect { priority: i, teacher: teacher_id }); - if teachers.contains(&t.id) && !checked { - None - } else { - let id = format!("{}_{}", name, j); - let teacher_id = t.id; - let onchange = ctx.link().callback(move |_| Msg::RadioSelect { priority: i, teacher: teacher_id }); - - Some(html! { -
- - -
+ Some(html! { + <> + +
+ + }) + } }) } - }) - } +
if i < self.slots - 1 {
@@ -278,28 +280,44 @@ impl Component for StudentVote { } }) } -
- - +
+
+ +
+
+ +
-
- - +
+
+ +
+
+ +