- NosOignons::Mailman.add_members(MEMBER_MAILING_LIST, uptodate_emails - current_emails)
- NosOignons::Mailman.remove_members(MEMBER_MAILING_LIST, current_emails - uptodate_emails)
+ def send_membership_reminders!
+ today = Time.now.to_date
+ NosOignons::Member.all.select(&:up_to_date?).each do |member|
+ NosOignons::Reminder.all.sort_by(&:days).reverse.each do |reminder|
+ anniversary = Time.new(today.year, member.joined_on.month,
+ member.joined_on.day).to_date
+
+ next if member.membership_fee_paid_on > anniversary
+ next if member.membership_fee_paid_on > today - reminder.days
+ next if anniversary > today - reminder.days
+ next if member.reminded_on && member.reminded_on >= today
+
+ member.remind(reminder)
+ break
+ end
+ end