Reorder methods in instructeur.rb

Move token stuff together, out of notification-related stuff.
This commit is contained in:
Nicolas Bouilleaud 2019-09-20 10:41:47 +02:00
parent 71db4ea32f
commit 8a06c01f13

View file

@ -137,11 +137,6 @@ class Instructeur < ApplicationRecord
Dossier.joins(:groupe_instructeur).where(id: dossiers_id_with_notifications(dossiers)).group('groupe_instructeurs.procedure_id').count
end
def create_trusted_device_token
trusted_device_token = trusted_device_tokens.create
trusted_device_token.token
end
def dossiers_id_with_notifications(dossiers)
dossiers = dossiers.followed_by(self)
@ -173,11 +168,6 @@ class Instructeur < ApplicationRecord
Follow.where(instructeur: self, dossier: dossier).update_all(attributes)
end
def young_login_token?
trusted_device_token = trusted_device_tokens.order(created_at: :desc).first
trusted_device_token&.token_young?
end
def email_notification_data
groupe_instructeur_with_email_notifications
.reduce([]) do |acc, groupe|
@ -199,6 +189,16 @@ class Instructeur < ApplicationRecord
end
end
def create_trusted_device_token
trusted_device_token = trusted_device_tokens.create
trusted_device_token.token
end
def young_login_token?
trusted_device_token = trusted_device_tokens.order(created_at: :desc).first
trusted_device_token&.token_young?
end
private
def annotations_hash(demande, annotations_privees, avis, messagerie)