3 # Système de gestion des adhésions de Nos oignons
4 # Copyright © 2013-2014 Nos oignons <contact@nos-oignons.net>
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Affero General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Affero General Public License for more details.
16 # You should have received a copy of the GNU Affero General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
24 DEFAULT_PATH = File.expand_path('../../../var/reminders.yaml', __FILE__)
29 ENV['NOS_OIGNONS_REMINDER_DB'] || DEFAULT_PATH
37 # hash of email => last_reminder_date
39 @reminders = YAML.load_file(db_path)
46 # save using atomic rename
47 file = Tempfile.new('reminder_db', File.dirname(db_path))
49 file.write(YAML.dump(@reminders))
51 File.rename file.path, db_path
58 def last_reminder(member)
59 @reminders[member.email]
63 @reminders[member.email] = Time.now.to_date
64 # Not efficient, but let's put people's mailbox as first priority