-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/delete-portfolio-item' of github.com:chibie/web…
… into feature/delete-portfolio-item
- Loading branch information
Showing
25 changed files
with
452 additions
and
251 deletions.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,41 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from grants.models import Grant, GrantStat | ||
|
||
|
||
class Command(BaseCommand): | ||
|
||
help = 'creates a grants snapshot' | ||
|
||
def handle(self, *args, **kwargs): | ||
for grant in Grant.objects.all(): | ||
# setup | ||
last_snapshot = grant.stats.filter(snapshot_type='total').order_by('-created_on').first() | ||
|
||
# snapshot | ||
data = { | ||
'impressions': grant.get_view_count, | ||
'in_cart': grant.cart_actions.filter(latest=True).count(), | ||
'contributions': grant.contribution_count | ||
} | ||
snapshot_type = 'total' | ||
GrantStat.objects.create( | ||
snapshot_type=snapshot_type, | ||
data=data, | ||
grant=grant, | ||
) | ||
|
||
# increment | ||
if last_snapshot: | ||
snapshot_type = "increment" | ||
increment_data = { | ||
} | ||
for key in data.keys(): | ||
increment_data[key] = data[key] - last_snapshot.data[key] | ||
GrantStat.objects.create( | ||
snapshot_type=snapshot_type, | ||
data=increment_data, | ||
grant=grant, | ||
) | ||
|
||
print(grant.pk) |
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,30 @@ | ||
# Generated by Django 2.2.4 on 2020-09-23 21:39 | ||
|
||
import django.contrib.postgres.fields.jsonb | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import economy.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('grants', '0086_grantcollections'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='GrantStat', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_on', models.DateTimeField(db_index=True, default=economy.models.get_time)), | ||
('modified_on', models.DateTimeField(default=economy.models.get_time)), | ||
('data', django.contrib.postgres.fields.jsonb.JSONField(blank=True, default=dict, help_text='Stats for this Grant')), | ||
('snapshot_type', models.CharField(choices=[('total', 'total'), ('increment', 'increment')], db_index=True, help_text='Snapshot Type', max_length=50)), | ||
('grant', models.ForeignKey(help_text='Grant to add stats for ', on_delete=django.db.models.deletion.CASCADE, related_name='stats', to='grants.Grant')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
), | ||
] |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,12 +57,12 @@ def test_handle_no_options(self, mock_weekly_roundup, *args): | |
|
||
assert mock_weekly_roundup.call_count == 0 | ||
|
||
@patch('time.sleep') | ||
@patch('marketing.management.commands.roundup.weekly_roundup') | ||
def test_handle_with_options(self, mock_weekly_roundup, *args): | ||
"""Test command roundup which various options.""" | ||
Command().handle(exclude_startswith='f', filter_startswith='jack', start_counter=0, live=True) | ||
# @patch('time.sleep') | ||
# @patch('marketing.management.commands.roundup.weekly_roundup') | ||
# def test_handle_with_options(self, mock_weekly_roundup, *args): | ||
# """Test command roundup which various options.""" | ||
# Command().handle(exclude_startswith='f', filter_startswith='jack', start_counter=0, live=True) | ||
|
||
assert mock_weekly_roundup.call_count == 1 | ||
# assert mock_weekly_roundup.call_count == 1 | ||
|
||
mock_weekly_roundup.assert_called_once_with(['[email protected]']) | ||
# mock_weekly_roundup.assert_called_once_with(['[email protected]']) |
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