From: Lunar Date: Mon, 3 Jun 2013 10:48:36 +0000 (+0200) Subject: Only call Mailman scripts when there is something to do X-Git-Url: https://nos-oignons.net/gitweb/gestion-adh.git/commitdiff_plain/7e897ab540f46c3850455111d70b3cbef654c557 Only call Mailman scripts when there is something to do --- diff --git a/lib/nos_oignons.rb b/lib/nos_oignons.rb index 26ffdc6..ff387d1 100644 --- a/lib/nos_oignons.rb +++ b/lib/nos_oignons.rb @@ -26,8 +26,10 @@ module NosOignons current_emails = NosOignons::Mailman.list_members(list) uptodate_emails = NosOignons::Member.all.select(&:up_to_date?).collect(&:email) - NosOignons::Mailman.add_members(list, uptodate_emails - current_emails) - NosOignons::Mailman.remove_members(list, current_emails - uptodate_emails) + emails_to_add = uptodate_emails - current_emails + NosOignons::Mailman.add_members(list, emails_to_add) unless emails_to_add.empty? + emails_to_remove = current_emails - uptodate_emails + NosOignons::Mailman.remove_members(list, emails_to_remove) unless emails_to_remove.empty? end def send_membership_reminders!