Update
This commit is contained in:
parent
a9fcab7add
commit
76ab5cbc87
|
@ -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"
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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|
|
||||
|
|
|
@ -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({
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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,9 +238,9 @@ impl Component for StudentVote {
|
|||
|
||||
html! {
|
||||
<>
|
||||
<fieldset>
|
||||
<fieldset class={classes!("fieldset")}>
|
||||
<legend>{ format!("{}. Wahl", i + 1) }</legend>
|
||||
|
||||
<div class={classes!("control")}>
|
||||
{
|
||||
for self.teachers.iter().enumerate().filter_map(|(j, t)| {
|
||||
let checked = curr_t == Some(&Some(t.id));
|
||||
|
@ -254,22 +253,25 @@ impl Component for StudentVote {
|
|||
let onchange = ctx.link().callback(move |_| Msg::RadioSelect { priority: i, teacher: teacher_id });
|
||||
|
||||
Some(html! {
|
||||
<div>
|
||||
<>
|
||||
<label class={classes!("radio")} key={id}>
|
||||
<input
|
||||
type="radio"
|
||||
id={id.to_owned()}
|
||||
name={name.to_owned()}
|
||||
value={t.user.name.to_owned()}
|
||||
required=true
|
||||
{onchange}
|
||||
{checked}
|
||||
/>
|
||||
<label for={id}>{ &t.user.name }</label>
|
||||
{ &t.user.name }
|
||||
</label>
|
||||
<br />
|
||||
</>
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</div>
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
</fieldset>
|
||||
if i < self.slots - 1 {
|
||||
<br />
|
||||
|
@ -278,28 +280,44 @@ impl Component for StudentVote {
|
|||
}
|
||||
}) }
|
||||
|
||||
<div>
|
||||
<button
|
||||
onclick={ctx.link().callback(|e: MouseEvent| {
|
||||
e.prevent_default();
|
||||
Msg::AddSlot
|
||||
})}
|
||||
>
|
||||
{ "+" }
|
||||
</button>
|
||||
<div class={classes!("field", "has-addons")}>
|
||||
<div class={classes!("control")}>
|
||||
<button
|
||||
onclick={ctx.link().callback(|e: MouseEvent| {
|
||||
e.prevent_default();
|
||||
Msg::RemoveSlot
|
||||
})}
|
||||
>
|
||||
{ "-" }
|
||||
<span class={classes!("icon", "is-small")}>
|
||||
<i class={classes!("fa-solid", "fa-minus")} />
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class={classes!("control")}>
|
||||
<button
|
||||
onclick={ctx.link().callback(|e: MouseEvent| {
|
||||
e.prevent_default();
|
||||
Msg::AddSlot
|
||||
})}
|
||||
>
|
||||
<span class={classes!("icon", "is-small")}>
|
||||
<i class={classes!("fa-solid", "fa-plus")} />
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<input type="submit" value="Submit" />
|
||||
<input type="reset" value="Reset" onclick={ctx.link().callback(|_| Msg::Reset)} />
|
||||
<div class={classes!("field", "is-grouped")}>
|
||||
<div class={classes!("control")}>
|
||||
<button class={classes!("button", "is-link")} type="submit">
|
||||
{ "Submit" }
|
||||
</button>
|
||||
</div>
|
||||
<div class={classes!("control")}>
|
||||
<button class={classes!("button")} type="reset" onclick={ctx.link().callback(|_| Msg::Reset)}>
|
||||
{ "Reset" }
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<components::graphql_errors::GraphQLErrors errors={self.errors.clone()} />
|
||||
|
|
Loading…
Reference in a new issue