-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Figures 0.4 learner progress overview performance boost #301
Merged
Merged
Changes from 20 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
509e7db
0.4 LPO performance update - figures.compat
johnbaldwin 7748be1
0.4 LPO performance update - new EnrollmentProgress class
johnbaldwin 7d27ab9
Light refactoring of pipeline 'enrollment_metrics' module
johnbaldwin 76716eb
0.4 LPO performance update - New EnrollmentData model
johnbaldwin 96ada6d
0.4 LPO performance update - Updated views and serializers
johnbaldwin 2d089ad
0.4 LPO performance update - figures.models - comment string
johnbaldwin f29c556
0.4 LPO performance update - backfill EnrollmentData first pass
johnbaldwin 35bbc6a
0.4 LPO performance update - Frontend API call change
johnbaldwin ff5e375
0.4 LPO performance update - devsite flake8 fix
johnbaldwin 1edae0b
0.4 LPO performance update - Add exception handling to compat
johnbaldwin 1b6b09e
0.4 LPO performance update - Add backfill exception handling
johnbaldwin 37c3990
0.4 LPO performance update - EnrollmentData update task and command
johnbaldwin a018f98
0.4 - performance update - Fix 0015 migration Ginkgo compat issue
johnbaldwin 9f29ea6
0.4 LPO performance update - figures.compat suppress pylint error
johnbaldwin fb90299
0.4 LPO performance improvement figures.serializers fix pylint error
johnbaldwin 5ec48d5
0.4 LPO performance update - Fixed enrollment data management command
johnbaldwin c2e6f69
0.4 LPO performance update - Skip Ginkgo test - CourseEnrollmentFactory
johnbaldwin 8bf3bf9
Merge branch 'master' into john/0.4-lpo-performance-boost
johnbaldwin 071e13a
Merge branch 'master' into john/0.4-lpo-performance-boost
johnbaldwin ac7fb39
Merge branch 'master' into john/0.4-lpo-performance-boost
johnbaldwin 5ed449f
0.4 LPO performance update - fix command update_figures_enrollment_data
johnbaldwin 4f63c45
Added missing 'sqlite' schema to devsite.settings
johnbaldwin f7bfa4a
0.4 LP performance update - pylint fix on figures.compat
johnbaldwin cc7ab5e
0.4 performance update - Fixed missing 'id' keyword arg figures.tasks
johnbaldwin a73fcbd
.gitignore update
johnbaldwin 82a9f42
0.4 LPO progress update - fixed task typo
johnbaldwin 65174d3
0.4 LPO performance update - Fixed dupe learners
johnbaldwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
figures/management/commands/update_figures_enrollment_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
"""This Django management command updates Figures EnrollmentData records | ||
|
||
Running this will trigger figures.tasks.update_enrollment_data for every site | ||
unless the '--site' option is used. Then it will update just that site | ||
""" | ||
from __future__ import print_function | ||
from __future__ import absolute_import | ||
from textwrap import dedent | ||
from django.contrib.sites.models import Site | ||
from django.core.management.base import BaseCommand | ||
from figures.tasks import update_enrollment_data | ||
|
||
|
||
def get_site(identifier): | ||
"""Quick-n-dirty function to let the caller choose the site id or domain | ||
Let the 'get' fail if record can't be found from the identifier | ||
""" | ||
try: | ||
filter_arg = dict(pk=int(identifier)) | ||
except ValueError: | ||
filter_arg = dict(domain=identifier) | ||
return Site.objects.get(**filter_arg) | ||
|
||
|
||
class Command(BaseCommand): | ||
"""Populate Figures metrics models | ||
|
||
Improvements | ||
""" | ||
help = dedent(__doc__).strip() | ||
|
||
def add_arguments(self, parser): | ||
parser.add_argument('--no-delay', | ||
action='store_true', | ||
default=False, | ||
help='Disable the celery "delay" directive') | ||
parser.add_argument('--site', | ||
help='backfill a specific site. provide id or domain name') | ||
|
||
def handle(self, *args, **options): | ||
print('BEGIN: Update Figures EnrollmentData') | ||
|
||
if options['site']: | ||
sites = [get_site(options['site'])] | ||
else: | ||
# Would be great to be able to filter out dead sites | ||
# Would be really great to be able to filter out dead sites | ||
# Would be really Really great to be able to filter out dead sites | ||
# Would be really Really REALLY great to be able to filter out dead sites | ||
|
||
sites = Site.objects.all() | ||
for site in sites: | ||
print('Updating EnrollmentData for site "{}"'.format(site.domain)) | ||
if options['no_delay']: | ||
update_enrollment_data(site) | ||
else: | ||
update_enrollment_data.delay(site=site) # pragma: no cover | ||
|
||
print('DONE: Update Figures EnrollmentData') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,53 @@ | ||||||
# -*- coding: utf-8 -*- | ||||||
# Generated by Django 1.11.29 on 2020-12-09 14:17 | ||||||
from __future__ import unicode_literals | ||||||
|
||||||
from django import VERSION as DJANGO_VERSION | ||||||
from django.conf import settings | ||||||
from django.db import migrations, models | ||||||
import django.db.models.deletion | ||||||
import django.utils.timezone | ||||||
import model_utils.fields | ||||||
|
||||||
|
||||||
class Migration(migrations.Migration): | ||||||
|
||||||
if DJANGO_VERSION[0:2] == (1,8): | ||||||
dependencies = [ | ||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||||||
('sites', '0001_initial'), | ||||||
('figures', '0014_add_indexes_to_daily_metrics'), | ||||||
] | ||||||
else: # Assuming 1.11+ | ||||||
dependencies = [ | ||||||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||||||
('sites', '0002_alter_domain_unique'), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work, no need to specify the latest migration from
Suggested change
|
||||||
('figures', '0014_add_indexes_to_daily_metrics'), | ||||||
] | ||||||
|
||||||
operations = [ | ||||||
migrations.CreateModel( | ||||||
name='EnrollmentData', | ||||||
fields=[ | ||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||||||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')), | ||||||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')), | ||||||
('course_id', models.CharField(db_index=True, max_length=255)), | ||||||
('date_for', models.DateField(db_index=True)), | ||||||
('date_enrolled', models.DateField(db_index=True)), | ||||||
('is_enrolled', models.BooleanField()), | ||||||
('is_completed', models.BooleanField()), | ||||||
('progress_percent', models.FloatField(default=0.0)), | ||||||
('points_possible', models.FloatField()), | ||||||
('points_earned', models.FloatField()), | ||||||
('sections_worked', models.IntegerField()), | ||||||
('sections_possible', models.IntegerField()), | ||||||
('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='sites.Site')), | ||||||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||||||
], | ||||||
), | ||||||
migrations.AlterUniqueTogether( | ||||||
name='enrollmentdata', | ||||||
unique_together=set([('site', 'user', 'course_id')]), | ||||||
), | ||||||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get you John. One idea is to soft delete: https://appsembler.atlassian.net/wiki/spaces/RT/blog/2020/12/10/1160708308/Soft+deleting+dead+sites
cc: @AhmedAljazzar