Skip to content
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

defer clr contribs #5268

Merged
merged 2 commits into from
Oct 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/grants/clr.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ def predict_clr(random_data=False, save_to_db=False, from_date=None):
all_summed_contributions.append({str(profile_id): sum_of_each_profiles_contributions})

# for each grant, list the contributions in key value pairs like {'profile id': sum of contributions}
contrib_data.append({'id': grant.id, 'contributions': all_summed_contributions})
grant_id = grant.defer_clr_to.pk if grant.defer_clr_to else grant.id
contrib_data.append({'id': grant_id, 'contributions': all_summed_contributions})

else:
# use random contribution data for testing
Expand Down
19 changes: 19 additions & 0 deletions app/grants/migrations/0033_grant_defer_clr_to.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 2.2.4 on 2019-10-04 21:54

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('grants', '0032_auto_20191001_1214'),
]

operations = [
migrations.AddField(
model_name='grant',
name='defer_clr_to',
field=models.ForeignKey(help_text='The Grant that this grant defers it CLR contributions to (if any).', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='defered_clr_from', to='grants.Grant'),
),
]
7 changes: 7 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ class Meta:
weighted_shuffle = models.PositiveIntegerField(blank=True, null=True)
contribution_count = models.PositiveIntegerField(blank=True, default=0)
contributor_count = models.PositiveIntegerField(blank=True, default=0)
defer_clr_to = models.ForeignKey(
'grants.Grant',
related_name='defered_clr_from',
on_delete=models.CASCADE,
help_text=_('The Grant that this grant defers it CLR contributions to (if any).'),
null=True,
)

# Grant Query Set used as manager.
objects = GrantQuerySet.as_manager()
Expand Down