Skip to content

Commit

Permalink
Merge pull request openedx-unsupported#33 from edx/travis-update
Browse files Browse the repository at this point in the history
Updates for Travis
  • Loading branch information
clintonb committed Oct 2, 2014
2 parents 0d6266f + 0487127 commit 2943787
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,8 @@ loaddata: syncdb

demo: clean requirements loaddata
python manage.py set_api_key edx edx

travis: clean requirements syncdb
python manage.py set_api_key edx edx
python manage.py loaddata education_levels problem_response_answer_distribution --database=analytics
python manage.py generate_fake_course_data --num-weeks=1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import datetime
import logging
from optparse import make_option
import random

from django.core.management.base import BaseCommand
Expand All @@ -28,6 +29,11 @@ def get_count(start):


class Command(BaseCommand):
help = 'Generate fake data'
option_list = BaseCommand.option_list + (
make_option('-n', '--num-weeks', action='store', type="int", dest='num_weeks', help='"Number of weeks worth of data to generate.'),
)

def generate_daily_data(self, course_id, start_date, end_date):
# Use the preset ratios below to generate data in the specified demographics

Expand Down Expand Up @@ -129,7 +135,8 @@ def generate_weekly_data(self, course_id, start_date, end_date):
models.CourseActivityWeekly.objects.create(course_id=course_id, activity_type=activity_type,
count=count, interval_start=start, interval_end=end)

models.CourseActivityWeekly.objects.create(course_id=course_id, activity_type='ACTIVE', count=active_students,
models.CourseActivityWeekly.objects.create(course_id=course_id, activity_type='ACTIVE',
count=active_students,
interval_start=start, interval_end=end)

start = end
Expand All @@ -139,7 +146,13 @@ def generate_weekly_data(self, course_id, start_date, end_date):
def handle(self, *args, **options):
course_id = 'edX/DemoX/Demo_Course'
start_date = datetime.datetime(year=2014, month=1, day=1, tzinfo=timezone.utc)
end_date = timezone.now().replace(microsecond=0)

num_weeks = options['num_weeks']
if num_weeks:
end_date = start_date + datetime.timedelta(weeks=num_weeks)
else:
end_date = timezone.now().replace(microsecond=0)

logger.info("Generating data for %s...", course_id)
self.generate_weekly_data(course_id, start_date, end_date)
self.generate_daily_data(course_id, start_date, end_date)

0 comments on commit 2943787

Please sign in to comment.