Skip to content

Commit

Permalink
Light refactor for fetching admins (decidim#9287)
Browse files Browse the repository at this point in the history
* Remove duplicated 'organization_admins' method

* Replace ActiveRecord query by 'admins' relation from organization model
  • Loading branch information
Quentinchampenois authored and eliegaboriau committed Oct 25, 2022
1 parent 564632b commit 783a2f2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,9 @@ def notify_support_threshold_reached(before, after)
event: "decidim.events.initiatives.support_threshold_reached",
event_class: Decidim::Initiatives::Admin::SupportThresholdReachedEvent,
resource: initiative,
followers: organization_admins
followers: initiative.organization.admins
)
end

def organization_admins
Decidim::User.where(organization: initiative.organization, admin: true)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def notify_admins(conflict)
event: "decidim.events.verifications.managed_user_error_event",
event_class: Decidim::Verifications::ManagedUserErrorEvent,
resource: conflict,
affected_users: Decidim::User.where(admin: true, organization: @organization)
affected_users: @organization.admins
)
end

Expand Down

0 comments on commit 783a2f2

Please sign in to comment.