Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
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-analytics-data-api
Commits
6e81e131
Commit
6e81e131
authored
Mar 18, 2017
by
Jillian Vogel
Committed by
GitHub
Mar 18, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #162 from open-craft/jill/es_agg_search_size
Make ElasticSearch aggregate search results size configurable
parents
54a80164
87d555b0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
analytics_data_api/v0/models.py
+6
-3
analytics_data_api/v0/tests/views/test_learners.py
+24
-0
analyticsdataserver/settings/base.py
+1
-0
No files found.
analytics_data_api/v0/models.py
View file @
6e81e131
...
@@ -407,11 +407,14 @@ class RosterEntry(DocType):
...
@@ -407,11 +407,14 @@ class RosterEntry(DocType):
}
}
}
}
"""
"""
# Use the configured default page size to set the number of aggregate search results.
page_size
=
getattr
(
settings
,
'AGGREGATE_PAGE_SIZE'
,
10
)
search
=
cls
.
search
()
search
=
cls
.
search
()
search
.
query
=
Q
(
'bool'
,
must
=
[
Q
(
'term'
,
course_id
=
course_id
)])
search
.
query
=
Q
(
'bool'
,
must
=
[
Q
(
'term'
,
course_id
=
course_id
)])
search
.
aggs
.
bucket
(
'enrollment_modes'
,
'terms'
,
field
=
'enrollment_mode'
)
search
.
aggs
.
bucket
(
'enrollment_modes'
,
'terms'
,
field
=
'enrollment_mode'
,
size
=
page_size
)
search
.
aggs
.
bucket
(
'segments'
,
'terms'
,
field
=
'segments'
)
search
.
aggs
.
bucket
(
'segments'
,
'terms'
,
field
=
'segments'
,
size
=
page_size
)
search
.
aggs
.
bucket
(
'cohorts'
,
'terms'
,
field
=
'cohort'
)
search
.
aggs
.
bucket
(
'cohorts'
,
'terms'
,
field
=
'cohort'
,
size
=
page_size
)
response
=
search
.
execute
()
response
=
search
.
execute
()
# Build up the map of aggregation name to count
# Build up the map of aggregation name to count
aggregations
=
{
aggregations
=
{
...
...
analytics_data_api/v0/tests/views/test_learners.py
View file @
6e81e131
...
@@ -14,6 +14,7 @@ from rest_framework import status
...
@@ -14,6 +14,7 @@ from rest_framework import status
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core
import
management
from
django.core
import
management
from
django.test
import
override_settings
from
analyticsdataserver.tests
import
TestCaseWithAuthentication
from
analyticsdataserver.tests
import
TestCaseWithAuthentication
from
analytics_data_api.constants
import
engagement_events
from
analytics_data_api.constants
import
engagement_events
...
@@ -769,6 +770,29 @@ class CourseLearnerMetadataTests(VerifyCourseIdMixin, LearnerAPITestMixin, TestC
...
@@ -769,6 +770,29 @@ class CourseLearnerMetadataTests(VerifyCourseIdMixin, LearnerAPITestMixin, TestC
)
)
self
.
assert_response_matches
(
self
.
_get
(
course_id
),
200
,
expected
)
self
.
assert_response_matches
(
self
.
_get
(
course_id
),
200
,
expected
)
@ddt.data
(
(
CourseSamples
.
course_ids
[
0
],
[],
{}),
(
CourseSamples
.
course_ids
[
1
],
[
'Yellow'
],
{
'Yellow'
:
1
}),
(
CourseSamples
.
course_ids
[
1
],
[
'Yellow'
,
'Green'
],
{
'Yellow'
:
1
,
'Green'
:
1
}),
(
CourseSamples
.
course_ids
[
0
],
[
'Red'
,
'Red'
,
'yellow team'
,
'green'
],
{
'Red'
:
2
,
'green'
:
1
}),
)
@ddt.unpack
@override_settings
(
AGGREGATE_PAGE_SIZE
=
2
)
def
test_cohorts_page_size
(
self
,
course_id
,
cohorts
,
expected_cohorts
):
""" Ensure that the AGGREGATE_PAGE_SIZE sets the max number of cohorts returned."""
self
.
create_learners
([
{
'username'
:
'user_{}'
.
format
(
i
),
'course_id'
:
course_id
,
'cohort'
:
cohort
}
for
i
,
cohort
in
enumerate
(
cohorts
)
])
expected
=
self
.
get_expected_json
(
course_id
=
course_id
,
segments
=
{
'disengaging'
:
0
,
'struggling'
:
0
,
'highly_engaged'
:
0
,
'inactive'
:
0
,
'unenrolled'
:
0
},
enrollment_modes
=
{
'honor'
:
len
(
cohorts
)}
if
cohorts
else
{},
cohorts
=
expected_cohorts
,
)
self
.
assert_response_matches
(
self
.
_get
(
course_id
),
200
,
expected
)
@property
@property
def
empty_engagement_ranges
(
self
):
def
empty_engagement_ranges
(
self
):
""" Returns the engagement ranges where all fields are set to None. """
""" Returns the engagement ranges where all fields are set to None. """
...
...
analyticsdataserver/settings/base.py
View file @
6e81e131
...
@@ -310,6 +310,7 @@ ENABLED_REPORT_IDENTIFIERS = ('problem_response',)
...
@@ -310,6 +310,7 @@ ENABLED_REPORT_IDENTIFIERS = ('problem_response',)
# Warning: using 0 or None for these can alter the structure of the REST response.
# Warning: using 0 or None for these can alter the structure of the REST response.
DEFAULT_PAGE_SIZE
=
25
DEFAULT_PAGE_SIZE
=
25
MAX_PAGE_SIZE
=
100
MAX_PAGE_SIZE
=
100
AGGREGATE_PAGE_SIZE
=
10
########## END ANALYTICS DATA API CONFIGURATION
########## END ANALYTICS DATA API CONFIGURATION
...
...
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