mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-13 00:24:42 +08:00
logic / migration updates
This commit is contained in:
parent
dd2a4a4047
commit
370a0ecad5
5 changed files with 12 additions and 7 deletions
|
@ -187,10 +187,6 @@ class MyModulesController < ApplicationController
|
|||
log_activity(:rename_task) if name_changed
|
||||
log_start_date_change_activity(start_date_changes) if start_date_changes.present?
|
||||
log_due_date_change_activity(due_date_changes) if due_date_changes.present?
|
||||
|
||||
if due_date_changes
|
||||
@my_module.update(notification_sent: false)
|
||||
end
|
||||
end
|
||||
end
|
||||
if saved
|
||||
|
|
|
@ -6,7 +6,6 @@ class DueDateReminderJob < ApplicationJob
|
|||
|
||||
my_modules.each do |task|
|
||||
TaskDueDateNotification.send_notifications({ my_module_id: task.id })
|
||||
task.update(notification_sent: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,6 +20,7 @@ class MyModule < ApplicationRecord
|
|||
|
||||
before_validation :archiving_and_restoring_extras, on: :update, if: :archived_changed?
|
||||
before_save -> { report_elements.destroy_all }, if: -> { !new_record? && experiment_id_changed? }
|
||||
before_save :reset_due_date_notification_sent, if: -> { due_date_changed? }
|
||||
around_save :exec_status_consequences, if: :my_module_status_id_changed?
|
||||
before_create :create_blank_protocol
|
||||
before_create :assign_default_status_flow
|
||||
|
@ -140,7 +141,8 @@ class MyModule < ApplicationRecord
|
|||
end
|
||||
|
||||
def self.approaching_due_dates
|
||||
where(notification_sent: false).select { |task| task.is_one_day_prior? }
|
||||
where(due_date_notification_sent: false)
|
||||
.where("due_date > ? AND due_date <= ?", DateTime.current, DateTime.current + 1.day)
|
||||
end
|
||||
|
||||
def parent
|
||||
|
@ -533,6 +535,10 @@ class MyModule < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def reset_due_date_notification_sent
|
||||
self.due_date_notification_sent = false
|
||||
end
|
||||
|
||||
def archiving_and_restoring_extras
|
||||
if archived?
|
||||
# Removes connections with other modules
|
||||
|
|
|
@ -17,4 +17,8 @@ class TaskDueDateNotification < BaseNotification
|
|||
def subject
|
||||
MyModule.find(params[:my_module_id])
|
||||
end
|
||||
|
||||
after_deliver do
|
||||
MyModule.find(params[:my_module_id]).update(due_date_notification_sent: true)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class AddTaskDueDateReminderNotification < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
add_column :my_modules, :notification_sent, :boolean, default: false
|
||||
add_column :my_modules, :due_date_notification_sent, :boolean, default: false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue