Skip to content

Commit

Permalink
⚡ loading subject attendance
Browse files Browse the repository at this point in the history
  • Loading branch information
RustySnek committed Dec 16, 2024
1 parent a9fc491 commit 8d53ea9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/elixirus/token_worker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ defmodule Elixirus.TokenWorker do
%Client{} = client = Client.get_client(token)

case SnakeArgs.from_params(:elixirus, :announcements, [client])
|> python!(timeout: 10_000) do
|> python!(python_timeout: 10_000) do
{:error, :timeout} ->
Logger.info("Timed out refreshing")

Expand Down
2 changes: 1 addition & 1 deletion lib/elixirus_web/live/student_live/attendance.ex
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ defmodule ElixirusWeb.StudentLive.Attendance do
end)
|> create_fetcher(user_id, subject_frequency, :subject_frequency, fn ->
SnakeArgs.from_params(:elixirus, :subject_frequency, [client])
|> Venomous.python!(timeout: 30_000)
|> Venomous.python!(python_timeout: 20_000)
end)
|> create_fetcher(user_id, attendance, :attendance, fn ->
{SnakeArgs.from_params(:elixirus, :attendance, [client, true])
Expand Down
14 changes: 13 additions & 1 deletion lib/elixirus_web/live/student_live/attendance.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,20 @@
</div>
</div>

<.link
:if={@live_action == nil}
class="h-20 rounded bg-fg shadow-md flex items-center justify-center"
navigate={~p"/student/attendance/subjects"}
replace={false}
>
View subject frequency
</.link>
<div :if={@live_action == :subject_frequency && :subject_frequency in @loadings}>
Loading...
</div>

<div
:if={@subject_frequency != []}
:if={@live_action == :subject_frequency && :subject_frequency not in @loadings}
class="flex flex-col gap-y-4 xl:max-h-[400px] md:flex-wrap items-center "
>
<div :for={{subj, freq} <- @subject_frequency} class="select-none w-full xl:w-1/4">
Expand Down
5 changes: 2 additions & 3 deletions lib/elixirus_web/live/student_live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ defmodule ElixirusWeb.StudentLive.Index do
:attendance => attendance_discards,
:announcement => announcement_discards
}
|> dbg

{:noreply, push_event(socket, "discard-all", discards)}
end
Expand Down Expand Up @@ -597,8 +596,8 @@ defmodule ElixirusWeb.StudentLive.Index do
>
<div class="flex flex-col">
<span><%= key %></span>
<div class="flex flex-row gap-x-1" :if={val != ""}>
<p :if={val != ""} :for={val <- Map.values(val)}>
<div :if={val != ""} class="flex flex-row gap-x-1">
<p :for={val <- Map.values(val)} :if={val != ""}>
<%= val %>
</p>
</div>
Expand Down
1 change: 1 addition & 0 deletions lib/elixirus_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ defmodule ElixirusWeb.Router do

scope "/attendance" do
live "/", StudentLive.Attendance
live "/subjects", StudentLive.Attendance, :subject_frequency
live "/:href", StudentLive.Attendance, :view
end

Expand Down

0 comments on commit 8d53ea9

Please sign in to comment.