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
edx
edx-platform
Commits
97248433
Unverified
Commit
97248433
authored
Oct 18, 2017
by
Tyler Hallada
Committed by
Gabe Mulley
Oct 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Group by user in the upgrade_reminder task
parent
68d5fe89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
15 deletions
+12
-15
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+7
-6
openedx/core/djangoapps/schedules/tasks.py
+5
-9
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
97248433
...
@@ -34,8 +34,9 @@ NUM_QUERIES_NO_MATCHING_SCHEDULES = 2
...
@@ -34,8 +34,9 @@ NUM_QUERIES_NO_MATCHING_SCHEDULES = 2
NUM_QUERIES_WITH_MATCHES
=
NUM_QUERIES_NO_MATCHING_SCHEDULES
+
1
NUM_QUERIES_WITH_MATCHES
=
NUM_QUERIES_NO_MATCHING_SCHEDULES
+
1
# 1) Global dynamic deadline switch
# 1) Global dynamic deadline switch
# 2) Course dynamic deadline switch
# 2) E-commerce configuration
# 2) E-commerce configuration
NUM_QUERIES_WITH_DEADLINE
=
2
NUM_QUERIES_WITH_DEADLINE
=
3
NUM_COURSE_MODES_QUERIES
=
1
NUM_COURSE_MODES_QUERIES
=
1
...
@@ -233,7 +234,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -233,7 +234,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
bin_num
=
user
.
id
%
tasks
.
UPGRADE_REMINDER_NUM_BINS
,
bin_num
=
user
.
id
%
tasks
.
UPGRADE_REMINDER_NUM_BINS
,
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
)
)
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
3
)
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
1
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
@ddt.data
(
*
itertools
.
product
((
1
,
10
,
100
),
(
2
,
10
)))
@ddt.data
(
*
itertools
.
product
((
1
,
10
,
100
),
(
2
,
10
)))
...
@@ -281,7 +282,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -281,7 +282,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
# we execute one query per course to see if it's opted out of dynamic upgrade deadlines, however,
# we execute one query per course to see if it's opted out of dynamic upgrade deadlines, however,
# 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
+
message_count
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_bin
(
tasks
.
upgrade_reminder_schedule_bin
(
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
,
...
@@ -289,15 +290,15 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
...
@@ -289,15 +290,15 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
)
)
self
.
assertEqual
(
len
(
sent_messages
),
message_count
)
self
.
assertEqual
(
len
(
sent_messages
),
1
)
# Load the site (which we query per message sent)
# Load the site (which we query per message sent)
# Check the schedule config
# Check the schedule config
with
self
.
assertNumQueries
(
1
+
message_count
):
with
self
.
assertNumQueries
(
2
):
for
args
in
sent_messages
:
for
args
in
sent_messages
:
tasks
.
_upgrade_reminder_schedule_send
(
*
args
)
tasks
.
_upgrade_reminder_schedule_send
(
*
args
)
self
.
assertEqual
(
mock_channel
.
deliver
.
call_count
,
message_count
)
self
.
assertEqual
(
mock_channel
.
deliver
.
call_count
,
1
)
for
(
_name
,
(
_msg
,
email
),
_kwargs
)
in
mock_channel
.
deliver
.
mock_calls
:
for
(
_name
,
(
_msg
,
email
),
_kwargs
)
in
mock_channel
.
deliver
.
mock_calls
:
for
template
in
attr
.
astuple
(
email
):
for
template
in
attr
.
astuple
(
email
):
self
.
assertNotIn
(
"TEMPLATE WARNING"
,
template
)
self
.
assertNotIn
(
"TEMPLATE WARNING"
,
template
)
...
...
openedx/core/djangoapps/schedules/tasks.py
View file @
97248433
...
@@ -222,16 +222,11 @@ def _upgrade_reminder_schedules_for_bin(site, current_datetime, target_datetime,
...
@@ -222,16 +222,11 @@ def _upgrade_reminder_schedules_for_bin(site, current_datetime, target_datetime,
exclude_orgs
=
exclude_orgs
,
exclude_orgs
=
exclude_orgs
,
)
)
for
schedule
in
schedules
:
for
(
user
,
user_schedules
)
in
groupby
(
schedules
,
lambda
s
:
s
.
enrollment
.
user
):
enrollment
=
schedule
.
enrollment
user_schedules
=
list
(
user_schedules
)
user
=
enrollment
.
user
course_id_strs
=
[
str
(
schedule
.
enrollment
.
course_id
)
for
schedule
in
user_schedules
]
course_id_str
=
str
(
enrollment
.
course_id
)
# TODO: group by schedule and user like recurring nudge
course_id_strs
=
[
course_id_str
]
first_schedule
=
schedule
first_schedule
=
user_schedules
[
0
]
template_context
=
get_base_template_context
(
site
)
template_context
=
get_base_template_context
(
site
)
template_context
.
update
({
template_context
.
update
({
'student_name'
:
user
.
profile
.
name
,
'student_name'
:
user
.
profile
.
name
,
...
@@ -242,6 +237,7 @@ def _upgrade_reminder_schedules_for_bin(site, current_datetime, target_datetime,
...
@@ -242,6 +237,7 @@ def _upgrade_reminder_schedules_for_bin(site, current_datetime, target_datetime,
# This is used by the bulk email optout policy
# This is used by the bulk email optout policy
'course_ids'
:
course_id_strs
,
'course_ids'
:
course_id_strs
,
'cert_image'
:
absolute_url
(
site
,
static
(
'course_experience/images/verified-cert.png'
)),
'cert_image'
:
absolute_url
(
site
,
static
(
'course_experience/images/verified-cert.png'
)),
})
})
...
...
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