Remove old notification extends [SCI-9384]

This commit is contained in:
Anton 2023-10-12 11:38:19 +02:00
parent f2b834cc14
commit 726ff5e238
3 changed files with 5 additions and 17 deletions

View file

@ -2,14 +2,10 @@
class Notification < ApplicationRecord
has_many :user_notifications, inverse_of: :notification, dependent: :destroy
has_many :users, through: :user_notifications
belongs_to :generator_user, class_name: 'User', optional: true
include Noticed::Model
belongs_to :recipient, polymorphic: true
enum type_of: Extends::NOTIFICATIONS_TYPES
private
def can_send_to_user?(_user)

View file

@ -14,13 +14,6 @@ class Extends
# Extends enum types. Should not be freezed, as modules might append to this.
# !!!Check all addons for the correct order!!!
# DEPRECATED 'system_message' in (SCI-2952, kept b/c of integer enums)
NOTIFICATIONS_TYPES = { assignment: 0,
recent_changes: 1,
system_message: 2, # DEPRECATED
deliver: 5,
deliver_error: 7 }
TASKS_STATES = { uncompleted: 0,
completed: 1 }

View file

@ -9,10 +9,10 @@ class MigrateNotificationToNoticed < ActiveRecord::Migration[7.0]
add_column :notifications, :recipient_type, :string
type_mapping = {
'assignment' => 'ActivityNotification',
'recent_changes' => 'GeneralNotification',
'deliver' => 'DeliveryNotification',
'deliver_error' => 'DeliveryNotification'
0 => 'ActivityNotification',
1 => 'GeneralNotification',
5 => 'DeliveryNotification',
7 => 'DeliveryNotification'
}
UserNotification.includes(:notification).find_each do |user_notification|
@ -26,8 +26,7 @@ class MigrateNotificationToNoticed < ActiveRecord::Migration[7.0]
legacy: true
}
params[:error] = notification.type_of == 'deliver_error' if new_type == 'DeliveryNotification'
params[:error] = notification.type_of == 7 if new_type == 'DeliveryNotification'
notification.update(
params: params,
type: new_type,