<commit_before>from rdrf.email_notification import process_notification

class Reminder:
    def __init__(self, user, registry_model):
        self.registry_model = registry_model
        self.user = user

    def _can_send(self):
        pass

    def send(self):
        if self._can_send():
            template_data = {"user": self.user,
                             "registry": self.registry_model}
    
            process_notification(self.registry_model.code,
                                 "reminder",
                                 template_data)
    <commit_msg>mtm #129 rules for sending<commit_after>from rdrf.email_notification import process_notification
from datetime import datetime
import logging

logger = logger.getLogger(__name__)

class ReminderProcessor:
    def __init__(self, user, registry_model):
        self.registry_model = registry_model
        self.user = user

    def _can_send(self):
        # These are the rules for MTM - should we push into config?
        now = datetime.now()
        existing_reminders = self._get_reminders()
        num_sent = len(existing_reminders)
        if num_sent >= 2:
            return False
        elif num_sent == 1:
            last_reminder = existing_reminders[-1]
            delta = now - last_reminder.date
            return  delta.days >= 14
        else:
            return True

    def _get_reminders(self):
        # to do - look at email notification history
        return []
        

    def process(self):
        if self._can_send():
            template_data = {"user": self.user,
                             "registry": self.registry_model}
    
            process_notification(self.registry_model.code,
                                 "reminder",
                                 template_data)
    
{'fraction_non_alphanumeric': 0.07277777777777777, 'fraction_numerical': 0.0044444444444444444, 'mean_word_length': 1.7622699386503067, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '476796', 'n_tokens_mistral': 473, 'n_tokens_neox': 465, 'n_words': 115}