Skip to content

Commit

Permalink
Never remove exercises that are part of an evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
jorg-vr committed Nov 10, 2023
1 parent e4a4977 commit e600ffb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/jobs/remove_activities_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ class RemoveActivitiesJob < ApplicationJob
# permanently remove activities that match all of the following criteria:
# - status is 'removed'
# - updated_at is more than 1 month ago
# - not part of an evaluation
# - one of the following is true:
# - draft is true (never published)
# - series_memberships is empty and less then 25 submissions and latest submission is more than 1 month ago
Expand All @@ -28,6 +29,8 @@ def perform
next if activity.submissions.present? && activity.submissions.reorder(:created_at).last.created_at > 1.month.ago
end

next if EvaluationExercise.exists?(exercise_id: activity.id)

# destroy submissions first explicitly, as they are dependent: :restrict_with_error
activity.submissions.destroy_all

Expand Down

0 comments on commit e600ffb

Please sign in to comment.