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

Remove PhantomFunding #9404

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
23 changes: 2 additions & 21 deletions app/grants/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

import twitter
from grants.models import (
CartActivity, CLRMatch, Contribution, Flag, Grant, GrantBrandingRoutingPolicy, GrantCLR, GrantCLRCalculation,
GrantCollection, GrantStat, GrantTag, GrantType, MatchPledge, PhantomFunding, Subscription,
CartActivity, CLRMatch, Contribution, Flag, Grant, GrantBrandingRoutingPolicy, GrantTag, GrantCLR,
GrantCLRCalculation, GrantCollection, GrantStat, GrantType, MatchPledge, Subscription,
)
from grants.views import record_grant_activity_helper
from marketing.mails import grant_more_info_required, new_grant_approved
Expand Down Expand Up @@ -410,24 +410,6 @@ def response_change(self, request, obj):
return redirect(obj.admin_url)


class PhantomFundingAdmin(admin.ModelAdmin):
"""Define the GeneralAdmin administration layout."""

ordering = ['-id']
list_display = ['id', 'github_created_on', 'from_ip_address', '__str__']
raw_id_fields = ['profile', 'grant']

def github_created_on(self, instance):
return naturaltime(instance.profile.github_created_on)

def from_ip_address(self, instance):
end = instance.created_on + timezone.timedelta(hours=1)
start = instance.created_on - timezone.timedelta(hours=1)
visits = set(instance.profile.actions.filter(created_on__gt=start, created_on__lte=end).values_list('ip_address', flat=True))
visits = [visit for visit in visits if visit]
return " , ".join(visits)


class CartActivityAdmin(admin.ModelAdmin):
list_display = ['id', 'grant', 'profile', 'action', 'bulk', 'latest', 'created_on']
raw_id_fields = ['grant', 'profile']
Expand Down Expand Up @@ -537,7 +519,6 @@ class GrantBrandingRoutingPolicyAdmin(admin.ModelAdmin):
list_display = ['pk', 'policy_name', 'url_pattern', 'priority' ]


admin.site.register(PhantomFunding, PhantomFundingAdmin)
admin.site.register(MatchPledge, MatchPledgeAdmin)
admin.site.register(Grant, GrantAdmin)
admin.site.register(Flag, FlagAdmin)
Expand Down
16 changes: 16 additions & 0 deletions app/grants/migrations/0124_delete_phantomfunding.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 2.2.24 on 2021-09-23 22:30

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('grants', '0123_auto_20210726_0703'),
]

operations = [
migrations.DeleteModel(
name='PhantomFunding',
),
]
1 change: 0 additions & 1 deletion app/grants/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,4 @@
from .grant_tag import GrantTag
from .grant_type import GrantType
from .match_pledge import MatchPledge
from .phantom_funding import PhantomFunding
from .subscription import Subscription
2 changes: 1 addition & 1 deletion app/grants/models/clr_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ class CLRMatch(SuperModel):

def __str__(self):
"""Return the string representation of a Grant."""
return f"id: {self.pk}, grant: {self.grant.pk}, round: {self.round_number}, amount: {self.amount}"
return f"id: {self.pk}, grant: {self.grant.pk}, round: {self.round_number}, amount: {self.amount}"
3 changes: 1 addition & 2 deletions app/grants/models/grant.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ class Meta:
)

in_active_clrs = models.ManyToManyField(
GrantCLR,
"GrantCLR",
thelostone-mc marked this conversation as resolved.
Show resolved Hide resolved
help_text="Active Grants CLR Round"
)
is_clr_active = models.BooleanField(default=False, help_text=_('CLR Round active or not? (auto computed)'))
Expand Down Expand Up @@ -885,7 +885,6 @@ def save(self, update=True, *args, **kwargs):

self.clr_prediction_curve = self.calc_clr_prediction_curve
self.clr_round_num = self.calc_clr_round_label

self.search_vector = (
SearchVector('title', weight='A') + SearchVector('description', weight='B')
)
Expand Down
2 changes: 1 addition & 1 deletion app/grants/models/match_pledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ def data_json(self):

def __str__(self):
"""Return the string representation of this object."""
return f"{self.profile} <> {self.amount} DAI"
return f"{self.profile} <> {self.amount} DAI"
49 changes: 0 additions & 49 deletions app/grants/models/phantom_funding.py

This file was deleted.

2 changes: 1 addition & 1 deletion app/grants/models/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,4 +554,4 @@ def create_contribution(self, tx_id, is_successful_contribution=True):
successful_contribution(self.grant, self, contribution)

update_grant_metadata.delay(self.pk)
return contribution
return contribution
5 changes: 2 additions & 3 deletions app/marketing/management/commands/post_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from dashboard.models import Activity, Earning, Profile
from economy.utils import convert_token_to_usdt
from grants.models import *
from grants.models import CartActivity, Contribution, PhantomFunding
from grants.models import CartActivity, Contribution
from grants.utils import get_clr_rounds_metadata
from townsquare.models import Comment

Expand Down Expand Up @@ -308,8 +308,7 @@ def grants():
contributions = Contribution.objects.filter(created_on__gt=start, created_on__lt=end, subscription_network='mainnet')#, subscription__grant__in=grants_pks)
if must_be_successful:
contributions = contributions.filter(success=True)
pfs = PhantomFunding.objects.filter(created_on__gt=start, created_on__lt=end)
total = contributions.count() + pfs.count()
total = contributions.count()

current_carts = CartActivity.objects.filter(created_on__gt=start, latest=True)#, grant__in=grants_pks)
num_carts = 0
Expand Down
9 changes: 4 additions & 5 deletions scripts/debug/add_squelched_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from django.utils import timezone

from grants.models import *
from grants.models import Contribution, PhantomFunding
from grants.models import Contribution
from grants.utils import get_clr_rounds_metadata

# total stats
Expand All @@ -12,11 +12,10 @@
_, round_start_date, round_end_date, _ = get_clr_rounds_metadata()

contributions = Contribution.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date, success=True)
pfs = PhantomFunding.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date)
total = contributions.count() + pfs.count()
total = contributions.count()

contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True)) + list(pfs.values_list('profile', flat=True))))
amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions] + [float(pf.value) for pf in pfs])
contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True))))
amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions])

print("contributions", total)
print("contributors", contributors)
Expand Down
9 changes: 4 additions & 5 deletions scripts/debug/address_usage_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@
from django.utils import timezone

from grants.models import *
from grants.models import Contribution, PhantomFunding, Subscription
from grants.models import Contribution, Subscription
from grants.utils import get_clr_rounds_metadata

# total stats

_, round_start_date, round_end_date, _ = get_clr_rounds_metadata()

contributions = Contribution.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date, success=True)
pfs = PhantomFunding.objects.filter(created_on__gt=round_start_date, created_on__lt=round_end_date)
total = contributions.count() + pfs.count()
total = contributions.count()

contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True)) + list(pfs.values_list('profile', flat=True))))
amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions] + [float(pf.value) for pf in pfs])
contributors = len(set(list(contributions.values_list('subscription__contributor_profile', flat=True))))
amount = sum([float(contrib.subscription.amount_per_period_usdt) for contrib in contributions])

print("contributions", total)
print("contributors", contributors)
Expand Down