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
ef3cbc51
Commit
ef3cbc51
authored
Jul 23, 2014
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sorting data chronologically
This will better serve the needs of the dashboard.
parent
6fc3d10a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
7 deletions
+21
-7
analytics_data_api/v0/models.py
+5
-5
analytics_data_api/v0/tests/test_views.py
+6
-2
analytics_data_api/v0/views/courses.py
+10
-0
No files found.
analytics_data_api/v0/models.py
View file @
ef3cbc51
...
@@ -42,7 +42,7 @@ class BaseCourseEnrollment(models.Model):
...
@@ -42,7 +42,7 @@ class BaseCourseEnrollment(models.Model):
class
CourseEnrollmentDaily
(
BaseCourseEnrollment
):
class
CourseEnrollmentDaily
(
BaseCourseEnrollment
):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
db_table
=
'course_enrollment_daily'
db_table
=
'course_enrollment_daily'
ordering
=
(
'
-
date'
,
'course'
)
ordering
=
(
'date'
,
'course'
)
unique_together
=
[(
'course'
,
'date'
,)]
unique_together
=
[(
'course'
,
'date'
,)]
...
@@ -51,7 +51,7 @@ class CourseEnrollmentByBirthYear(BaseCourseEnrollment):
...
@@ -51,7 +51,7 @@ class CourseEnrollmentByBirthYear(BaseCourseEnrollment):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
db_table
=
'course_enrollment_birth_year'
db_table
=
'course_enrollment_birth_year'
ordering
=
(
'
-date'
,
'birth_year'
,
'course
'
)
ordering
=
(
'
date'
,
'course'
,
'birth_year
'
)
unique_together
=
[(
'course'
,
'date'
,
'birth_year'
)]
unique_together
=
[(
'course'
,
'date'
,
'birth_year'
)]
...
@@ -71,7 +71,7 @@ class CourseEnrollmentByEducation(BaseCourseEnrollment):
...
@@ -71,7 +71,7 @@ class CourseEnrollmentByEducation(BaseCourseEnrollment):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
db_table
=
'course_enrollment_education_level'
db_table
=
'course_enrollment_education_level'
ordering
=
(
'
-date'
,
'education_level'
,
'course
'
)
ordering
=
(
'
date'
,
'course'
,
'education_level
'
)
unique_together
=
[(
'course'
,
'date'
,
'education_level'
)]
unique_together
=
[(
'course'
,
'date'
,
'education_level'
)]
...
@@ -80,7 +80,7 @@ class CourseEnrollmentByGender(BaseCourseEnrollment):
...
@@ -80,7 +80,7 @@ class CourseEnrollmentByGender(BaseCourseEnrollment):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
db_table
=
'course_enrollment_gender'
db_table
=
'course_enrollment_gender'
ordering
=
(
'
-date'
,
'gender'
,
'course
'
)
ordering
=
(
'
date'
,
'course'
,
'gender
'
)
unique_together
=
[(
'course'
,
'date'
,
'gender'
)]
unique_together
=
[(
'course'
,
'date'
,
'gender'
)]
...
@@ -120,5 +120,5 @@ class CourseEnrollmentByCountry(BaseCourseEnrollment):
...
@@ -120,5 +120,5 @@ class CourseEnrollmentByCountry(BaseCourseEnrollment):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
class
Meta
(
BaseCourseEnrollment
.
Meta
):
db_table
=
'course_enrollment_location'
db_table
=
'course_enrollment_location'
ordering
=
(
'
-date'
,
'country'
,
'course
'
)
ordering
=
(
'
date'
,
'course'
,
'country
'
)
unique_together
=
[(
'course'
,
'date'
,
'country'
)]
unique_together
=
[(
'course'
,
'date'
,
'country'
)]
analytics_data_api/v0/tests/test_views.py
View file @
ef3cbc51
...
@@ -84,6 +84,7 @@ class CourseActivityLastWeekTest(TestCaseWithAuthentication):
...
@@ -84,6 +84,7 @@ class CourseActivityLastWeekTest(TestCaseWithAuthentication):
class
CourseEnrollmentViewTestCase
(
object
):
class
CourseEnrollmentViewTestCase
(
object
):
model
=
None
model
=
None
path
=
None
path
=
None
order_by
=
[]
def
_get_non_existent_course_id
(
self
):
def
_get_non_existent_course_id
(
self
):
course_id
=
random
.
randint
(
100
,
9999
)
course_id
=
random
.
randint
(
100
,
9999
)
...
@@ -108,8 +109,8 @@ class CourseEnrollmentViewTestCase(object):
...
@@ -108,8 +109,8 @@ class CourseEnrollmentViewTestCase(object):
response
=
self
.
authenticated_get
(
'/api/v0/courses/
%
s
%
s'
%
(
self
.
course
.
course_id
,
self
.
path
,))
response
=
self
.
authenticated_get
(
'/api/v0/courses/
%
s
%
s'
%
(
self
.
course
.
course_id
,
self
.
path
,))
self
.
assertEquals
(
response
.
status_code
,
200
)
self
.
assertEquals
(
response
.
status_code
,
200
)
# Validate the
actual data
# Validate the
data is correct and sorted chronologically
expected
=
self
.
get_expected_response
(
*
self
.
model
.
objects
.
filter
(
date
=
self
.
date
)
)
expected
=
self
.
get_expected_response
(
*
self
.
model
.
objects
.
filter
(
date
=
self
.
date
)
.
order_by
(
'date'
,
*
self
.
order_by
))
# pylint: disable=line-too-long
self
.
assertEquals
(
response
.
data
,
expected
)
self
.
assertEquals
(
response
.
data
,
expected
)
def
test_get_csv
(
self
):
def
test_get_csv
(
self
):
...
@@ -167,6 +168,7 @@ class CourseEnrollmentViewTestCase(object):
...
@@ -167,6 +168,7 @@ class CourseEnrollmentViewTestCase(object):
class
CourseEnrollmentByBirthYearViewTests
(
TestCaseWithAuthentication
,
CourseEnrollmentViewTestCase
):
class
CourseEnrollmentByBirthYearViewTests
(
TestCaseWithAuthentication
,
CourseEnrollmentViewTestCase
):
path
=
'/enrollment/birth_year'
path
=
'/enrollment/birth_year'
model
=
models
.
CourseEnrollmentByBirthYear
model
=
models
.
CourseEnrollmentByBirthYear
order_by
=
[
'birth_year'
]
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
...
@@ -197,6 +199,7 @@ class CourseEnrollmentByBirthYearViewTests(TestCaseWithAuthentication, CourseEnr
...
@@ -197,6 +199,7 @@ class CourseEnrollmentByBirthYearViewTests(TestCaseWithAuthentication, CourseEnr
class
CourseEnrollmentByEducationViewTests
(
TestCaseWithAuthentication
,
CourseEnrollmentViewTestCase
):
class
CourseEnrollmentByEducationViewTests
(
TestCaseWithAuthentication
,
CourseEnrollmentViewTestCase
):
path
=
'/enrollment/education/'
path
=
'/enrollment/education/'
model
=
models
.
CourseEnrollmentByEducation
model
=
models
.
CourseEnrollmentByEducation
order_by
=
[
'education_level'
]
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
...
@@ -219,6 +222,7 @@ class CourseEnrollmentByEducationViewTests(TestCaseWithAuthentication, CourseEnr
...
@@ -219,6 +222,7 @@ class CourseEnrollmentByEducationViewTests(TestCaseWithAuthentication, CourseEnr
class
CourseEnrollmentByGenderViewTests
(
TestCaseWithAuthentication
,
CourseEnrollmentViewTestCase
):
class
CourseEnrollmentByGenderViewTests
(
TestCaseWithAuthentication
,
CourseEnrollmentViewTestCase
):
path
=
'/enrollment/gender/'
path
=
'/enrollment/gender/'
model
=
models
.
CourseEnrollmentByGender
model
=
models
.
CourseEnrollmentByGender
order_by
=
[
'gender'
]
@classmethod
@classmethod
def
setUpClass
(
cls
):
def
setUpClass
(
cls
):
...
...
analytics_data_api/v0/views/courses.py
View file @
ef3cbc51
...
@@ -91,6 +91,8 @@ class CourseEnrollmentByBirthYearView(BaseCourseEnrollmentView):
...
@@ -91,6 +91,8 @@ class CourseEnrollmentByBirthYearView(BaseCourseEnrollmentView):
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
Data is sorted chronologically (earliest to latest).
Date format: YYYY-mm-dd (e.g. 2014-01-31)
Date format: YYYY-mm-dd (e.g. 2014-01-31)
start_date -- Date after which all data should be returned (inclusive)
start_date -- Date after which all data should be returned (inclusive)
...
@@ -109,6 +111,8 @@ class CourseEnrollmentByEducationView(BaseCourseEnrollmentView):
...
@@ -109,6 +111,8 @@ class CourseEnrollmentByEducationView(BaseCourseEnrollmentView):
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
Data is sorted chronologically (earliest to latest).
Date format: YYYY-mm-dd (e.g. 2014-01-31)
Date format: YYYY-mm-dd (e.g. 2014-01-31)
start_date -- Date after which all data should be returned (inclusive)
start_date -- Date after which all data should be returned (inclusive)
...
@@ -131,6 +135,8 @@ class CourseEnrollmentByGenderView(BaseCourseEnrollmentView):
...
@@ -131,6 +135,8 @@ class CourseEnrollmentByGenderView(BaseCourseEnrollmentView):
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
Data is sorted chronologically (earliest to latest).
Date format: YYYY-mm-dd (e.g. 2014-01-31)
Date format: YYYY-mm-dd (e.g. 2014-01-31)
start_date -- Date after which all data should be returned (inclusive)
start_date -- Date after which all data should be returned (inclusive)
...
@@ -146,6 +152,8 @@ class CourseEnrollmentView(BaseCourseEnrollmentView):
...
@@ -146,6 +152,8 @@ class CourseEnrollmentView(BaseCourseEnrollmentView):
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
Data is sorted chronologically (earliest to latest).
Date format: YYYY-mm-dd (e.g. 2014-01-31)
Date format: YYYY-mm-dd (e.g. 2014-01-31)
start_date -- Date after which all data should be returned (inclusive)
start_date -- Date after which all data should be returned (inclusive)
...
@@ -168,6 +176,8 @@ class CourseEnrollmentByLocationView(BaseCourseEnrollmentView):
...
@@ -168,6 +176,8 @@ class CourseEnrollmentByLocationView(BaseCourseEnrollmentView):
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
If no start or end dates are passed, the data for the latest date is returned. All dates should are in the UTC zone.
Data is sorted chronologically (earliest to latest).
Date format: YYYY-mm-dd (e.g. 2014-01-31)
Date format: YYYY-mm-dd (e.g. 2014-01-31)
start_date -- Date after which all data should be returned (inclusive)
start_date -- Date after which all data should be returned (inclusive)
...
...
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