[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DB crash due to timeout #1031

Merged
merged 9 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update Avenger backlog notification workers
Fixes compatibilty with new function signature.
  • Loading branch information
RichDom2185 committed Nov 6, 2023
commit af5c9e17e1d9ea7e46196dba103484a67cda3926
11 changes: 3 additions & 8 deletions lib/cadet/workers/NotificationWorker.ex
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,10 @@ defmodule Cadet.Workers.NotificationWorker do
for avenger_cr <- avengers_crs do
avenger = Cadet.Accounts.get_user(avenger_cr.user_id)

ungraded_submissions =
Jason.decode!(
elem(
Cadet.Assessments.all_submissions_by_grader_for_index(avenger_cr, true, true),
1
)
)
{:ok, %{submissions: ungraded_submissions}} =
Cadet.Assessments.all_submissions_by_grader_for_index(avenger_cr, true, true)

if length(ungraded_submissions) < ungraded_threshold do
if Enum.count(ungraded_submissions) < ungraded_threshold do
IO.puts("[AVENGER_BACKLOG] below threshold!")
else
IO.puts("[AVENGER_BACKLOG] SENDING_OUT")
Expand Down
6 changes: 2 additions & 4 deletions test/cadet/email_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ defmodule Cadet.EmailTest do
avenger_user = insert(:user, %{email: "test@gmail.com"})
avenger = insert(:course_registration, %{user: avenger_user, role: :staff})

ungraded_submissions =
Jason.decode!(
elem(Cadet.Assessments.all_submissions_by_grader_for_index(avenger, true, true), 1)
)
{:ok, %{submissions: ungraded_submissions}} =
Cadet.Assessments.all_submissions_by_grader_for_index(avenger, true, true)

email = Email.avenger_backlog_email("avenger_backlog", avenger_user, ungraded_submissions)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ defmodule Cadet.NotificationWorker.NotificationWorkerTest do
submission = List.first(List.first(data.mcq_answers)).submission

# setup for avenger backlog
ungraded_submissions =
Jason.decode!(
elem(Cadet.Assessments.all_submissions_by_grader_for_index(avenger_cr, true, true), 1)
)
{:ok, %{submissions: ungraded_submissions}} =
Cadet.Assessments.all_submissions_by_grader_for_index(avenger_cr, true, true)

Repo.update_all(NotificationType, set: [is_enabled: true])
Repo.update_all(NotificationConfig, set: [is_enabled: true])
Expand Down