Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
edx-platform
Commits
303a8c93
Commit
303a8c93
authored
Oct 18, 2017
by
Calen Pennington
Committed by
Dillon Dumesnil
Oct 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert bin-scheduling tasks into classes
parent
fa26a31a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
64 deletions
+73
-64
openedx/core/djangoapps/schedules/management/commands/send_course_update.py
+2
-2
openedx/core/djangoapps/schedules/management/commands/send_recurring_nudge.py
+2
-2
openedx/core/djangoapps/schedules/management/commands/send_upgrade_reminder.py
+2
-2
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+10
-10
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+5
-5
openedx/core/djangoapps/schedules/tasks.py
+52
-43
No files found.
openedx/core/djangoapps/schedules/management/commands/send_course_update.py
View file @
303a8c93
from
openedx.core.djangoapps.schedules.management.commands
import
SendEmailBaseCommand
from
openedx.core.djangoapps.schedules.management.commands
import
SendEmailBaseCommand
from
openedx.core.djangoapps.schedules.resolvers
import
CourseUpdateResolver
from
openedx.core.djangoapps.schedules.resolvers
import
CourseUpdateResolver
from
openedx.core.djangoapps.schedules.tasks
import
course_update_schedule_bin
from
openedx.core.djangoapps.schedules.tasks
import
ScheduleCourseUpdate
class
Command
(
SendEmailBaseCommand
):
class
Command
(
SendEmailBaseCommand
):
resolver_class
=
CourseUpdateResolver
resolver_class
=
CourseUpdateResolver
async_send_task
=
course_update_schedule_bin
async_send_task
=
ScheduleCourseUpdate
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Command
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
Command
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
...
openedx/core/djangoapps/schedules/management/commands/send_recurring_nudge.py
View file @
303a8c93
from
openedx.core.djangoapps.schedules.management.commands
import
SendEmailBaseCommand
from
openedx.core.djangoapps.schedules.management.commands
import
SendEmailBaseCommand
from
openedx.core.djangoapps.schedules.resolvers
import
ScheduleStartResolver
from
openedx.core.djangoapps.schedules.resolvers
import
ScheduleStartResolver
from
openedx.core.djangoapps.schedules.tasks
import
recurring_nudge_schedule_bin
from
openedx.core.djangoapps.schedules.tasks
import
ScheduleRecurringNudge
class
Command
(
SendEmailBaseCommand
):
class
Command
(
SendEmailBaseCommand
):
resolver_class
=
ScheduleStartResolver
resolver_class
=
ScheduleStartResolver
async_send_task
=
recurring_nudge_schedule_bin
async_send_task
=
ScheduleRecurringNudge
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Command
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
Command
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
...
openedx/core/djangoapps/schedules/management/commands/send_upgrade_reminder.py
View file @
303a8c93
from
openedx.core.djangoapps.schedules.management.commands
import
SendEmailBaseCommand
from
openedx.core.djangoapps.schedules.management.commands
import
SendEmailBaseCommand
from
openedx.core.djangoapps.schedules.resolvers
import
UpgradeReminderResolver
from
openedx.core.djangoapps.schedules.resolvers
import
UpgradeReminderResolver
from
openedx.core.djangoapps.schedules.tasks
import
upgrade_reminder_schedule_bin
from
openedx.core.djangoapps.schedules.tasks
import
ScheduleUpgradeReminder
class
Command
(
SendEmailBaseCommand
):
class
Command
(
SendEmailBaseCommand
):
resolver_class
=
UpgradeReminderResolver
resolver_class
=
UpgradeReminderResolver
async_send_task
=
upgrade_reminder_schedule_bin
async_send_task
=
ScheduleUpgradeReminder
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
Command
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
Command
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
...
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
303a8c93
...
@@ -112,7 +112,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -112,7 +112,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
expected_queries
+=
NUM_COURSE_MODES_QUERIES
expected_queries
+=
NUM_COURSE_MODES_QUERIES
with
self
.
assertNumQueries
(
expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
recurring_nudge_schedule_bi
n
(
tasks
.
ScheduleRecurringNudge
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
b
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
b
,
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
)
)
...
@@ -132,7 +132,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -132,7 +132,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime_str
=
serialize
(
test_datetime
)
test_datetime_str
=
serialize
(
test_datetime
)
for
b
in
range
(
resolvers
.
RECURRING_NUDGE_NUM_BINS
):
for
b
in
range
(
resolvers
.
RECURRING_NUDGE_NUM_BINS
):
with
self
.
assertNumQueries
(
NUM_QUERIES_NO_MATCHING_SCHEDULES
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
NUM_QUERIES_NO_MATCHING_SCHEDULES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
recurring_nudge_schedule_bi
n
(
tasks
.
ScheduleRecurringNudge
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
b
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
b
,
org_list
=
[
schedule
.
enrollment
.
course
.
org
],
org_list
=
[
schedule
.
enrollment
.
course
.
org
],
)
)
...
@@ -159,7 +159,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -159,7 +159,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
20
,
tzinfo
=
pytz
.
UTC
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
20
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
test_datetime_str
=
serialize
(
test_datetime
)
tasks
.
recurring_nudge_schedule_bin
.
apply_async
(
tasks
.
ScheduleRecurringNudge
.
apply_async
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
0
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
0
,
org_list
=
[
schedule
.
enrollment
.
course
.
org
],
org_list
=
[
schedule
.
enrollment
.
course
.
org
],
)
)
...
@@ -229,7 +229,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -229,7 +229,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
tzinfo
=
pytz
.
UTC
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
test_datetime_str
=
serialize
(
test_datetime
)
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
recurring_nudge_schedule_bi
n
(
tasks
.
ScheduleRecurringNudge
()
.
ru
n
(
limited_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
0
,
limited_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
0
,
org_list
=
org_list
,
exclude_orgs
=
exclude_orgs
,
org_list
=
org_list
,
exclude_orgs
=
exclude_orgs
,
)
)
...
@@ -253,7 +253,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -253,7 +253,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
test_datetime_str
=
serialize
(
test_datetime
)
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
recurring_nudge_schedule_bi
n
(
tasks
.
ScheduleRecurringNudge
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
user
.
id
%
resolvers
.
RECURRING_NUDGE_NUM_BINS
,
bin_num
=
user
.
id
%
resolvers
.
RECURRING_NUDGE_NUM_BINS
,
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
...
@@ -292,7 +292,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -292,7 +292,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
mock_schedule_send
.
apply_async
=
lambda
args
,
*
_a
,
**
_kw
:
sent_messages
.
append
(
args
)
mock_schedule_send
.
apply_async
=
lambda
args
,
*
_a
,
**
_kw
:
sent_messages
.
append
(
args
)
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
recurring_nudge_schedule_bi
n
(
tasks
.
ScheduleRecurringNudge
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
day
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
day
,
bin_num
=
self
.
_calculate_bin_for_user
(
user
),
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
bin_num
=
self
.
_calculate_bin_for_user
(
user
),
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
)
)
...
@@ -339,7 +339,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -339,7 +339,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
user
,
user
,
schedule
.
enrollment
.
course
.
org
schedule
.
enrollment
.
course
.
org
]
]
sent_messages
=
self
.
_stub_sender_and_collect_sent_messages
(
bin_task
=
tasks
.
recurring_nudge_schedule_bin
,
sent_messages
=
self
.
_stub_sender_and_collect_sent_messages
(
bin_task
=
tasks
.
ScheduleRecurringNudge
,
stubbed_send_task
=
patch
.
object
(
tasks
,
'_recurring_nudge_schedule_send'
),
stubbed_send_task
=
patch
.
object
(
tasks
,
'_recurring_nudge_schedule_send'
),
bin_task_params
=
bin_task_parameters
)
bin_task_params
=
bin_task_parameters
)
...
@@ -371,7 +371,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -371,7 +371,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
user
,
user
,
schedule
.
enrollment
.
course
.
org
schedule
.
enrollment
.
course
.
org
]
]
sent_messages
=
self
.
_stub_sender_and_collect_sent_messages
(
bin_task
=
tasks
.
recurring_nudge_schedule_bin
,
sent_messages
=
self
.
_stub_sender_and_collect_sent_messages
(
bin_task
=
tasks
.
ScheduleRecurringNudge
,
stubbed_send_task
=
patch
.
object
(
tasks
,
'_recurring_nudge_schedule_send'
),
stubbed_send_task
=
patch
.
object
(
tasks
,
'_recurring_nudge_schedule_send'
),
bin_task_params
=
bin_task_parameters
)
bin_task_params
=
bin_task_parameters
)
...
@@ -410,7 +410,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -410,7 +410,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
user
,
user
,
schedule
.
enrollment
.
course
.
org
schedule
.
enrollment
.
course
.
org
]
]
sent_messages
=
self
.
_stub_sender_and_collect_sent_messages
(
bin_task
=
tasks
.
recurring_nudge_schedule_bin
,
sent_messages
=
self
.
_stub_sender_and_collect_sent_messages
(
bin_task
=
tasks
.
ScheduleRecurringNudge
,
stubbed_send_task
=
patch
.
object
(
tasks
,
'_recurring_nudge_schedule_send'
),
stubbed_send_task
=
patch
.
object
(
tasks
,
'_recurring_nudge_schedule_send'
),
bin_task_params
=
bin_task_parameters
)
bin_task_params
=
bin_task_parameters
)
...
@@ -426,7 +426,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -426,7 +426,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
mock_schedule_send
.
apply_async
=
lambda
args
,
*
_a
,
**
_kw
:
sent_messages
.
append
(
args
)
mock_schedule_send
.
apply_async
=
lambda
args
,
*
_a
,
**
_kw
:
sent_messages
.
append
(
args
)
bin_task
(
bin_task
(
)
.
run
(
self
.
site_config
.
site
.
id
,
self
.
site_config
.
site
.
id
,
target_day_str
=
bin_task_params
[
0
],
target_day_str
=
bin_task_params
[
0
],
day_offset
=
bin_task_params
[
1
],
day_offset
=
bin_task_params
[
1
],
...
...
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
303a8c93
...
@@ -116,7 +116,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -116,7 +116,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
expected_queries
+=
NUM_COURSE_MODES_QUERIES
expected_queries
+=
NUM_COURSE_MODES_QUERIES
with
self
.
assertNumQueries
(
expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
upgrade_reminder_schedule_bi
n
(
tasks
.
ScheduleUpgradeReminder
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
b
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
b
,
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
)
)
...
@@ -137,7 +137,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -137,7 +137,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime_str
=
serialize
(
test_datetime
)
test_datetime_str
=
serialize
(
test_datetime
)
for
b
in
range
(
resolvers
.
UPGRADE_REMINDER_NUM_BINS
):
for
b
in
range
(
resolvers
.
UPGRADE_REMINDER_NUM_BINS
):
with
self
.
assertNumQueries
(
NUM_QUERIES_NO_MATCHING_SCHEDULES
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
NUM_QUERIES_NO_MATCHING_SCHEDULES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
upgrade_reminder_schedule_bi
n
(
tasks
.
ScheduleUpgradeReminder
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
b
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
b
,
org_list
=
[
schedule
.
enrollment
.
course
.
org
],
org_list
=
[
schedule
.
enrollment
.
course
.
org
],
)
)
...
@@ -213,7 +213,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -213,7 +213,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
tzinfo
=
pytz
.
UTC
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
test_datetime_str
=
serialize
(
test_datetime
)
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
upgrade_reminder_schedule_bi
n
(
tasks
.
ScheduleUpgradeReminder
()
.
ru
n
(
limited_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
0
,
limited_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
0
,
org_list
=
org_list
,
exclude_orgs
=
exclude_orgs
,
org_list
=
org_list
,
exclude_orgs
=
exclude_orgs
,
)
)
...
@@ -237,7 +237,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -237,7 +237,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
19
,
44
,
30
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
test_datetime_str
=
serialize
(
test_datetime
)
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
upgrade_reminder_schedule_bi
n
(
tasks
.
ScheduleUpgradeReminder
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
user
.
id
%
resolvers
.
UPGRADE_REMINDER_NUM_BINS
,
bin_num
=
user
.
id
%
resolvers
.
UPGRADE_REMINDER_NUM_BINS
,
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
...
@@ -292,7 +292,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -292,7 +292,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
# since we create a new course for each schedule in this test, we expect there to be one per message
# since we create a new course for each schedule in this test, we expect there to be one per message
num_expected_queries
=
NUM_QUERIES_WITH_MATCHES
+
NUM_QUERIES_WITH_DEADLINE
num_expected_queries
=
NUM_QUERIES_WITH_MATCHES
+
NUM_QUERIES_WITH_DEADLINE
with
self
.
assertNumQueries
(
num_expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
with
self
.
assertNumQueries
(
num_expected_queries
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
upgrade_reminder_schedule_bi
n
(
tasks
.
ScheduleUpgradeReminder
()
.
ru
n
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
day
,
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
day
,
bin_num
=
self
.
_calculate_bin_for_user
(
user
),
bin_num
=
self
.
_calculate_bin_for_user
(
user
),
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
...
...
openedx/core/djangoapps/schedules/tasks.py
View file @
303a8c93
import
datetime
import
datetime
import
logging
import
logging
from
celery.task
import
task
from
celery.task
import
task
,
Task
from
django.conf
import
settings
from
django.conf
import
settings
from
django.contrib.sites.models
import
Site
from
django.contrib.sites.models
import
Site
from
django.contrib.staticfiles.templatetags.staticfiles
import
static
from
django.contrib.staticfiles.templatetags.staticfiles
import
static
...
@@ -65,36 +65,42 @@ def _recurring_nudge_schedule_send(site_id, msg_str):
...
@@ -65,36 +65,42 @@ def _recurring_nudge_schedule_send(site_id, msg_str):
ace
.
send
(
msg
)
ace
.
send
(
msg
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
class
ScheduleRecurringNudge
(
Task
):
def
recurring_nudge_schedule_bin
(
ignore_result
=
True
site_id
,
target_day_str
,
day_offset
,
bin_num
,
org_list
,
exclude_orgs
=
False
,
override_recipient_email
=
None
,
routing_key
=
ROUTING_KEY
):
return
resolvers
.
recurring_nudge_schedule_bin
(
def
run
(
_recurring_nudge_schedule_send
,
self
,
site_id
,
target_day_str
,
day_offset
,
bin_num
,
org_list
,
exclude_orgs
=
False
,
override_recipient_email
=
None
,
site_id
,
):
target_day_str
,
return
resolvers
.
recurring_nudge_schedule_bin
(
day_offset
,
_recurring_nudge_schedule_send
,
bin_num
,
site_id
,
org_list
,
target_day_str
,
exclude_orgs
=
exclude_orgs
,
day_offset
,
override_recipient_email
=
override_recipient_email
,
bin_num
,
)
org_list
,
exclude_orgs
=
exclude_orgs
,
override_recipient_email
=
override_recipient_email
,
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
class
ScheduleUpgradeReminder
(
Task
):
def
upgrade_reminder_schedule_bin
(
ignore_result
=
True
site_id
,
target_day_str
,
day_offset
,
bin_num
,
org_list
,
exclude_orgs
=
False
,
override_recipient_email
=
None
,
routing_key
=
ROUTING_KEY
):
return
resolvers
.
upgrade_reminder_schedule_bin
(
def
run
(
_upgrade_reminder_schedule_send
,
self
,
site_id
,
target_day_str
,
day_offset
,
bin_num
,
org_list
,
exclude_orgs
=
False
,
override_recipient_email
=
None
,
site_id
,
):
target_day_str
,
return
resolvers
.
upgrade_reminder_schedule_bin
(
day_offset
,
_upgrade_reminder_schedule_send
,
bin_num
,
site_id
,
org_list
,
target_day_str
,
exclude_orgs
=
exclude_orgs
,
day_offset
,
override_recipient_email
=
override_recipient_email
,
bin_num
,
)
org_list
,
exclude_orgs
=
exclude_orgs
,
override_recipient_email
=
override_recipient_email
,
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
def
_upgrade_reminder_schedule_send
(
site_id
,
msg_str
):
def
_upgrade_reminder_schedule_send
(
site_id
,
msg_str
):
...
@@ -106,20 +112,23 @@ def _upgrade_reminder_schedule_send(site_id, msg_str):
...
@@ -106,20 +112,23 @@ def _upgrade_reminder_schedule_send(site_id, msg_str):
ace
.
send
(
msg
)
ace
.
send
(
msg
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
class
ScheduleCourseUpdate
(
Task
):
def
course_update_schedule_bin
(
ignore_result
=
True
site_id
,
target_day_str
,
day_offset
,
bin_num
,
org_list
,
exclude_orgs
=
False
,
override_recipient_email
=
None
,
routing_key
=
ROUTING_KEY
):
return
resolvers
.
course_update_schedule_bin
(
def
run
(
_course_update_schedule_send
,
self
,
site_id
,
target_day_str
,
day_offset
,
bin_num
,
org_list
,
exclude_orgs
=
False
,
override_recipient_email
=
None
,
site_id
,
):
target_day_str
,
return
resolvers
.
course_update_schedule_bin
(
day_offset
,
_course_update_schedule_send
,
bin_num
,
site_id
,
org_list
,
target_day_str
,
exclude_orgs
=
exclude_orgs
,
day_offset
,
override_recipient_email
=
override_recipient_email
,
bin_num
,
)
org_list
,
exclude_orgs
=
exclude_orgs
,
override_recipient_email
=
override_recipient_email
,
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
@task
(
ignore_result
=
True
,
routing_key
=
ROUTING_KEY
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment