Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
fixup! review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Fischer committed May 23, 2017
1 parent 7280bcb commit bdc0c95
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,17 @@ def generate_daily_data(self, course_id, start_date, end_date):
progress.update(1)
date = date + datetime.timedelta(days=1)

for mode, ratio in enrollment_mode_ratios.iteritems():
for index, (mode, ratio) in enumerate(enrollment_mode_ratios.iteritems()):
count = int(ratio * daily_total)
pass_rate = min(random.normalvariate(.45 + (.1 * index), .15), 1.0)
cumulative_count = count + random.randint(0, 100)
models.CourseMetaSummaryEnrollment.objects.create(
course_id=course_id, catalog_course_title='Demo Course', catalog_course='Demo_Course',
start_time=timezone.now() - datetime.timedelta(weeks=6),
end_time=timezone.now() + datetime.timedelta(weeks=10),
pacing_type='self_paced', availability='Starting Soon', enrollment_mode=mode, count=count,
cumulative_count=cumulative_count, count_change_7_days=random.randint(-50, 50))
cumulative_count=cumulative_count, count_change_7_days=random.randint(-50, 50),
passing_users=int(cumulative_count * pass_rate))

models.CourseProgramMetadata.objects.create(course_id=course_id, program_id='Demo_Program',
program_type='Demo', program_title='Demo Program')
Expand Down
7 changes: 7 additions & 0 deletions analytics_data_api/v0/tests/views/test_course_summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,10 @@ def test_programs(self):
response = self.authenticated_get(self.path(exclude=self.always_exclude[:1], programs=['True']))
self.assertEquals(response.status_code, 200)
self.assertItemsEqual(response.data, self.all_expected_results(programs=True))

@ddt.data('passing_users', )
def test_exclude(self, field):
self.generate_data()
response = self.authenticated_get(self.path(exclude=[field]))
self.assertEquals(response.status_code, 200)
self.assertEquals(str(response.data).count(field), 0)
4 changes: 4 additions & 0 deletions analytics_data_api/v0/views/course_summaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ def postprocess_field_dict(self, field_dict):
# don't do expensive looping for programs if we are just going to throw it away
field_dict = self.add_programs(field_dict)

for field in self.exclude:
for mode in field_dict['enrollment_modes']:
_ = field_dict['enrollment_modes'][mode].pop(field, None)

return field_dict

def add_programs(self, field_dict):
Expand Down

0 comments on commit bdc0c95

Please sign in to comment.