Commit c19a3368 by Calen Pennington

Move MessageType definitions into tasks.py

parent e81931da
......@@ -22,7 +22,6 @@ from openedx.core.djangoapps.monitoring_utils import set_custom_metric, function
from openedx.core.djangoapps.schedules.config import COURSE_UPDATE_WAFFLE_FLAG
from openedx.core.djangoapps.schedules.exceptions import CourseUpdateDoesNotExist
from openedx.core.djangoapps.schedules.models import Schedule, ScheduleConfig
from openedx.core.djangoapps.schedules.message_type import ScheduleMessageType
from openedx.core.djangoapps.schedules.utils import PrefixedDebugLoggerMixin
from openedx.core.djangoapps.schedules.template_context import (
absolute_url,
......@@ -158,12 +157,6 @@ class BinnedSchedulesBaseResolver(PrefixedDebugLoggerMixin, RecipientResolver):
return schedules
class RecurringNudge(ScheduleMessageType):
def __init__(self, day, *args, **kwargs):
super(RecurringNudge, self).__init__(*args, **kwargs)
self.name = "recurringnudge_day{}".format(day)
def _annotate_for_monitoring(message_type, site, bin_num, target_datetime, day_offset):
# This identifies the type of message being sent, for example: schedules.recurring_nudge3.
set_custom_metric('message_name', '{0}.{1}'.format(
......@@ -225,9 +218,6 @@ def _get_datetime_beginning_of_day(dt):
return dt.replace(hour=0, minute=0, second=0, microsecond=0)
class UpgradeReminder(ScheduleMessageType):
pass
class UpgradeReminderResolver(BinnedSchedulesBaseResolver):
"""
Send a message to all users whose verified upgrade deadline is at ``self.current_date`` + ``day_offset``.
......@@ -295,10 +285,6 @@ def _get_link_to_purchase_verified_certificate(a_user, a_schedule):
return verified_upgrade_deadline_link(a_user, enrollment.course)
class CourseUpdate(ScheduleMessageType):
pass
class CourseUpdateResolver(BinnedSchedulesBaseResolver):
"""
Send a message to all users whose schedule started at ``self.current_date`` + ``day_offset`` and the
......
......@@ -20,6 +20,7 @@ from openedx.core.djangoapps.monitoring_utils import set_custom_metric
from openedx.core.djangoapps.schedules.models import Schedule, ScheduleConfig
from openedx.core.djangoapps.schedules import resolvers
from openedx.core.djangoapps.schedules.message_type import ScheduleMessageType
from openedx.core.djangoapps.site_configuration.models import SiteConfiguration
......@@ -167,6 +168,12 @@ def _recurring_nudge_schedule_send(site_id, msg_str):
ace.send(msg)
class RecurringNudge(ScheduleMessageType):
def __init__(self, day, *args, **kwargs):
super(RecurringNudge, self).__init__(*args, **kwargs)
self.name = "recurringnudge_day{}".format(day)
class ScheduleRecurringNudge(ScheduleMessageBaseTask):
num_bins = resolvers.RECURRING_NUDGE_NUM_BINS
enqueue_config_var = 'enqueue_recurring_nudge'
......@@ -175,7 +182,7 @@ class ScheduleRecurringNudge(ScheduleMessageBaseTask):
async_send_task = _recurring_nudge_schedule_send
def make_message_type(self, day_offset):
return resolvers.RecurringNudge(abs(day_offset))
return RecurringNudge(abs(day_offset))
@task(ignore_result=True, routing_key=ROUTING_KEY)
......@@ -192,6 +199,10 @@ def _upgrade_reminder_schedule_send(site_id, msg_str):
ace.send(msg)
class UpgradeReminder(ScheduleMessageType):
pass
class ScheduleUpgradeReminder(ScheduleMessageBaseTask):
num_bins = resolvers.UPGRADE_REMINDER_NUM_BINS
enqueue_config_var = 'enqueue_upgrade_reminder'
......@@ -200,7 +211,7 @@ class ScheduleUpgradeReminder(ScheduleMessageBaseTask):
async_send_task = _upgrade_reminder_schedule_send
def make_message_type(self, day_offset):
return resolvers.UpgradeReminder()
return UpgradeReminder()
......@@ -218,6 +229,10 @@ def _course_update_schedule_send(site_id, msg_str):
ace.send(msg)
class CourseUpdate(ScheduleMessageType):
pass
class ScheduleCourseUpdate(ScheduleMessageBaseTask):
num_bins = resolvers.COURSE_UPDATE_NUM_BINS
enqueue_config_var = 'enqueue_course_update'
......@@ -226,4 +241,4 @@ class ScheduleCourseUpdate(ScheduleMessageBaseTask):
async_send_task = _course_update_schedule_send
def make_message_type(self, day_offset):
return resolvers.CourseUpdate()
return CourseUpdate()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment