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
790fe79e
Commit
790fe79e
authored
Oct 17, 2017
by
Calen Pennington
Committed by
Dillon Dumesnil
Oct 31, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move bin-count constants into resolvers.py nearer to the queries that use them
parent
8bfe2e94
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
23 additions
and
26 deletions
+23
-26
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
+9
-9
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
+8
-8
openedx/core/djangoapps/schedules/resolvers.py
+5
-4
openedx/core/djangoapps/schedules/tasks.py
+0
-4
openedx/core/djangoapps/schedules/tests/test_resolvers.py
+1
-1
No files found.
openedx/core/djangoapps/schedules/management/commands/tests/test_send_recurring_nudge.py
View file @
790fe79e
...
...
@@ -81,7 +81,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
retry
=
False
,
)
mock_schedule_bin
.
apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
-
3
,
task
s
.
RECURRING_NUDGE_NUM_BINS
-
1
,
[],
True
,
None
),
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
-
3
,
resolver
s
.
RECURRING_NUDGE_NUM_BINS
-
1
,
[],
True
,
None
),
retry
=
False
,
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
...
...
@@ -97,11 +97,11 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
)
for
i
in
range
(
schedule_count
)
]
bins_in_use
=
frozenset
((
s
.
enrollment
.
user
.
id
%
task
s
.
RECURRING_NUDGE_NUM_BINS
)
for
s
in
schedules
)
bins_in_use
=
frozenset
((
s
.
enrollment
.
user
.
id
%
resolver
s
.
RECURRING_NUDGE_NUM_BINS
)
for
s
in
schedules
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
18
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
for
b
in
range
(
task
s
.
RECURRING_NUDGE_NUM_BINS
):
for
b
in
range
(
resolver
s
.
RECURRING_NUDGE_NUM_BINS
):
expected_queries
=
NUM_QUERIES_NO_MATCHING_SCHEDULES
if
b
in
bins_in_use
:
# to fetch course modes for valid schedules
...
...
@@ -126,7 +126,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
20
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
for
b
in
range
(
task
s
.
RECURRING_NUDGE_NUM_BINS
):
for
b
in
range
(
resolver
s
.
RECURRING_NUDGE_NUM_BINS
):
with
self
.
assertNumQueries
(
NUM_QUERIES_NO_MATCHING_SCHEDULES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
recurring_nudge_schedule_bin
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
b
,
...
...
@@ -143,7 +143,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
@patch.object
(
tasks
,
'_recurring_nudge_schedule_send'
)
def
test_send_after_course_end
(
self
,
mock_schedule_send
):
user1
=
UserFactory
.
create
(
id
=
task
s
.
RECURRING_NUDGE_NUM_BINS
)
user1
=
UserFactory
.
create
(
id
=
resolver
s
.
RECURRING_NUDGE_NUM_BINS
)
schedule
=
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
3
,
20
,
34
,
30
,
tzinfo
=
pytz
.
UTC
),
...
...
@@ -199,8 +199,8 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
for
config
in
(
limited_config
,
unlimited_config
):
ScheduleConfigFactory
.
create
(
site
=
config
.
site
)
user1
=
UserFactory
.
create
(
id
=
task
s
.
RECURRING_NUDGE_NUM_BINS
)
user2
=
UserFactory
.
create
(
id
=
task
s
.
RECURRING_NUDGE_NUM_BINS
*
2
)
user1
=
UserFactory
.
create
(
id
=
resolver
s
.
RECURRING_NUDGE_NUM_BINS
)
user2
=
UserFactory
.
create
(
id
=
resolver
s
.
RECURRING_NUDGE_NUM_BINS
*
2
)
ScheduleFactory
.
create
(
start
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
...
...
@@ -247,7 +247,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
recurring_nudge_schedule_bin
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=-
3
,
bin_num
=
user
.
id
%
task
s
.
RECURRING_NUDGE_NUM_BINS
,
bin_num
=
user
.
id
%
resolver
s
.
RECURRING_NUDGE_NUM_BINS
,
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
)
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
1
)
...
...
@@ -434,7 +434,7 @@ class TestSendRecurringNudge(FilteredQueryCountMixin, CacheIsolationTestCase):
return
templates_override
def
_calculate_bin_for_user
(
self
,
user
):
return
user
.
id
%
task
s
.
RECURRING_NUDGE_NUM_BINS
return
user
.
id
%
resolver
s
.
RECURRING_NUDGE_NUM_BINS
def
_contains_upsell_attribute
(
self
,
msg_attr
):
msg
=
Message
.
from_string
(
msg_attr
)
...
...
openedx/core/djangoapps/schedules/management/commands/tests/test_send_upgrade_reminder.py
View file @
790fe79e
...
...
@@ -85,7 +85,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
retry
=
False
,
)
mock_schedule_bin
.
apply_async
.
assert_any_call
(
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
2
,
task
s
.
UPGRADE_REMINDER_NUM_BINS
-
1
,
[],
True
,
None
),
(
self
.
site_config
.
site
.
id
,
serialize
(
test_day
),
2
,
resolver
s
.
UPGRADE_REMINDER_NUM_BINS
-
1
,
[],
True
,
None
),
retry
=
False
,
)
self
.
assertFalse
(
mock_ace
.
send
.
called
)
...
...
@@ -101,11 +101,11 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
)
for
i
in
range
(
schedule_count
)
]
bins_in_use
=
frozenset
((
s
.
enrollment
.
user
.
id
%
task
s
.
UPGRADE_REMINDER_NUM_BINS
)
for
s
in
schedules
)
bins_in_use
=
frozenset
((
s
.
enrollment
.
user
.
id
%
resolver
s
.
UPGRADE_REMINDER_NUM_BINS
)
for
s
in
schedules
)
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
18
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
for
b
in
range
(
task
s
.
UPGRADE_REMINDER_NUM_BINS
):
for
b
in
range
(
resolver
s
.
UPGRADE_REMINDER_NUM_BINS
):
expected_queries
=
NUM_QUERIES_NO_MATCHING_SCHEDULES
if
b
in
bins_in_use
:
# to fetch course modes for valid schedules
...
...
@@ -131,7 +131,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
test_datetime
=
datetime
.
datetime
(
2017
,
8
,
3
,
20
,
tzinfo
=
pytz
.
UTC
)
test_datetime_str
=
serialize
(
test_datetime
)
for
b
in
range
(
task
s
.
UPGRADE_REMINDER_NUM_BINS
):
for
b
in
range
(
resolver
s
.
UPGRADE_REMINDER_NUM_BINS
):
with
self
.
assertNumQueries
(
NUM_QUERIES_NO_MATCHING_SCHEDULES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
upgrade_reminder_schedule_bin
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
b
,
...
...
@@ -183,8 +183,8 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
for
config
in
(
limited_config
,
unlimited_config
):
ScheduleConfigFactory
.
create
(
site
=
config
.
site
)
user1
=
UserFactory
.
create
(
id
=
task
s
.
UPGRADE_REMINDER_NUM_BINS
)
user2
=
UserFactory
.
create
(
id
=
task
s
.
UPGRADE_REMINDER_NUM_BINS
*
2
)
user1
=
UserFactory
.
create
(
id
=
resolver
s
.
UPGRADE_REMINDER_NUM_BINS
)
user2
=
UserFactory
.
create
(
id
=
resolver
s
.
UPGRADE_REMINDER_NUM_BINS
*
2
)
ScheduleFactory
.
create
(
upgrade_deadline
=
datetime
.
datetime
(
2017
,
8
,
3
,
17
,
44
,
30
,
tzinfo
=
pytz
.
UTC
),
...
...
@@ -231,7 +231,7 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
with
self
.
assertNumQueries
(
NUM_QUERIES_WITH_MATCHES
,
table_blacklist
=
WAFFLE_TABLES
):
tasks
.
upgrade_reminder_schedule_bin
(
self
.
site_config
.
site
.
id
,
target_day_str
=
test_datetime_str
,
day_offset
=
2
,
bin_num
=
user
.
id
%
task
s
.
UPGRADE_REMINDER_NUM_BINS
,
bin_num
=
user
.
id
%
resolver
s
.
UPGRADE_REMINDER_NUM_BINS
,
org_list
=
[
schedules
[
0
]
.
enrollment
.
course
.
org
],
)
self
.
assertEqual
(
mock_schedule_send
.
apply_async
.
call_count
,
1
)
...
...
@@ -309,4 +309,4 @@ class TestUpgradeReminder(FilteredQueryCountMixin, CacheIsolationTestCase):
return
templates_override
def
_calculate_bin_for_user
(
self
,
user
):
return
user
.
id
%
task
s
.
RECURRING_NUDGE_NUM_BINS
return
user
.
id
%
resolver
s
.
RECURRING_NUDGE_NUM_BINS
openedx/core/djangoapps/schedules/resolvers.py
View file @
790fe79e
...
...
@@ -18,10 +18,6 @@ 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.tasks
import
(
DEFAULT_NUM_BINS
,
RECURRING_NUDGE_NUM_BINS
,
UPGRADE_REMINDER_NUM_BINS
,
COURSE_UPDATE_NUM_BINS
,
recurring_nudge_schedule_bin
,
upgrade_reminder_schedule_bin
,
course_update_schedule_bin
,
...
...
@@ -41,6 +37,11 @@ from xmodule.modulestore.django import modulestore
LOG
=
logging
.
getLogger
(
__name__
)
DEFAULT_NUM_BINS
=
24
RECURRING_NUDGE_NUM_BINS
=
DEFAULT_NUM_BINS
UPGRADE_REMINDER_NUM_BINS
=
DEFAULT_NUM_BINS
COURSE_UPDATE_NUM_BINS
=
DEFAULT_NUM_BINS
class
BinnedSchedulesBaseResolver
(
PrefixedDebugLoggerMixin
,
RecipientResolver
):
"""
Starts num_bins number of async tasks, each of which sends emails to an equal group of learners.
...
...
openedx/core/djangoapps/schedules/tasks.py
View file @
790fe79e
...
...
@@ -31,10 +31,6 @@ KNOWN_RETRY_ERRORS = ( # Errors we expect occasionally that could resolve on re
DatabaseError
,
ValidationError
,
)
DEFAULT_NUM_BINS
=
24
RECURRING_NUDGE_NUM_BINS
=
DEFAULT_NUM_BINS
UPGRADE_REMINDER_NUM_BINS
=
DEFAULT_NUM_BINS
COURSE_UPDATE_NUM_BINS
=
DEFAULT_NUM_BINS
@task
(
bind
=
True
,
default_retry_delay
=
30
,
routing_key
=
ROUTING_KEY
)
...
...
openedx/core/djangoapps/schedules/tests/test_resolvers.py
View file @
790fe79e
...
...
@@ -6,7 +6,7 @@ from django.conf import settings
from
mock
import
patch
from
openedx.core.djangoapps.schedules.resolvers
import
BinnedSchedulesBaseResolver
from
openedx.core.djangoapps.schedules.
task
s
import
DEFAULT_NUM_BINS
from
openedx.core.djangoapps.schedules.
resolver
s
import
DEFAULT_NUM_BINS
from
openedx.core.djangoapps.schedules.tests.factories
import
ScheduleConfigFactory
from
openedx.core.djangoapps.site_configuration.tests.factories
import
SiteConfigurationFactory
,
SiteFactory
from
openedx.core.djangolib.testing.utils
import
CacheIsolationTestCase
,
skip_unless_lms
...
...
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