Add a method to speed up a conditional statement

This commit is contained in:
gregoirenovel 2017-08-29 12:33:31 +02:00
parent 0a8ac645d8
commit 79eccb2de0
2 changed files with 5 additions and 1 deletions

View file

@ -92,6 +92,10 @@ class Dossier < ActiveRecord::Base
unreaded_notifications.order("created_at ASC").first
end
def was_piece_justificative_uploaded_for_type_id?(type_id)
pieces_justificatives.where(type_de_piece_justificative_id: type_id).count > 0
end
def retrieve_last_piece_justificative_by_type(type)
pieces_justificatives.where(type_de_piece_justificative_id: type).last
end