1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

(bug) Polymorphic joins for table supporting_document_files supportable

This commit is contained in:
Du Peng 2023-09-11 18:04:02 +02:00
parent 12b1ff5f0e
commit 0d4d0ec801

View File

@ -8,7 +8,7 @@ class SupportingDocumentsReminderWorker
users_to_notify = User.members
.supporting_documents_reminder_not_sent
.where("users.created_at < ?", 2.days.ago)
.left_outer_joins(supporting_document_files: { supporting_document_type: :groups })
.joins("LEFT OUTER JOIN supporting_document_files ON supporting_document_files.supportable_id = users.id AND supporting_document_files.supportable_type = 'User' LEFT OUTER JOIN supporting_document_types ON supporting_document_types.id = supporting_document_files.supporting_document_type_id LEFT OUTER JOIN supporting_document_types_groups ON supporting_document_types_groups.supporting_document_type_id = supporting_document_types.id LEFT OUTER JOIN groups ON groups.id = supporting_document_types_groups.group_id")
.where("groups.id = users.group_id OR groups.id IS NULL")
.select("users.*, count(supporting_document_files.id)")
.group("users.id")