Пример #1
0
    def handle(self, *args, **options):
        if settings.DEBUG:
            print("not active in non prod environments")
            return

        start_time = timezone.now() - timezone.timedelta(hours=36)
        end_time = timezone.now() - timezone.timedelta(hours=12)
        bounties_fulfilled_last_timeperiod = Bounty.objects.current().filter(
            network='mainnet',
            fulfillment_accepted_on__gt=start_time,
            fulfillment_accepted_on__lt=end_time,
            idx_status='done'
            ).values_list('pk', flat=True)
        bounties_cancelled_last_timeperiod = Bounty.objects.current().filter(
            network='mainnet',
            canceled_on__gt=start_time,
            canceled_on__lt=end_time,
            idx_status='cancelled'
            ).values_list('pk', flat=True)
        bounty_pks = list(bounties_cancelled_last_timeperiod) + list(bounties_fulfilled_last_timeperiod)
        bounties_to_process = Bounty.objects.filter(pk__in=bounty_pks)
        print(bounties_to_process.count())

        for bounty in bounties_to_process:

            (to_fulfiller, to_funder, fulfiller_previous_bounties, funder_previous_bounties) = handle_bounty_feedback(bounty)

            if to_fulfiller:
                bounty_feedback(bounty, 'fulfiller', fulfiller_previous_bounties)
            
            if to_funder:
                bounty_feedback(bounty, 'funder', funder_previous_bounties)
Пример #2
0
    def handle(self, *args, **options):
        if settings.DEBUG:
            print("not active in non prod environments")
            return

        start_time = timezone.now() - timezone.timedelta(hours=36)
        end_time = timezone.now() - timezone.timedelta(hours=12)
        statues = ['done', 'cancelled']
        bounties_fulfilled_last_timeperiod = Bounty.objects.filter(
            network='mainnet',
            current_bounty=True,
            fulfillment_accepted_on__gt=start_time,
            fulfillment_accepted_on__lt=end_time,
            idx_status='done').values_list('pk', flat=True)
        bounties_cancelled_last_timeperiod = Bounty.objects.filter(
            network='mainnet',
            current_bounty=True,
            canceled_on__gt=start_time,
            canceled_on__lt=end_time,
            idx_status='cancelled').values_list('pk', flat=True)
        bounty_pks = list(bounties_cancelled_last_timeperiod) + list(
            bounties_fulfilled_last_timeperiod)
        bounties_to_process = Bounty.objects.filter(pk__in=bounty_pks)
        print(bounties_to_process.count())
        for bounty in bounties_to_process:

            # identity
            submitter_email = bounty.bounty_owner_email
            is_fulfiller_and_funder_same_person = False

            # send email to the fulfiller
            accepted_fulfillments = bounty.fulfillments.filter(accepted=True)
            if accepted_fulfillments.exists() and bounty.status == 'done':
                accepted_fulfillment = accepted_fulfillments.first()
                fulfiller_email = accepted_fulfillment.fulfiller_email
                is_fulfiller_and_funder_same_person = (
                    fulfiller_email == submitter_email)
                fulfillment_pks = BountyFulfillment.objects.filter(
                    accepted=True,
                    fulfiller_email=fulfiller_email).values_list('pk',
                                                                 flat=True)
                previous_bounties = Bounty.objects.filter(
                    web3_created__lt=bounty.web3_created,
                    idx_status__in=statues,
                    fulfillments__pk__in=fulfillment_pks,
                    current_bounty=True).exclude(pk=bounty.pk).distinct()
                has_been_sent_before_to_persona = previous_bounties.count()
                if not has_been_sent_before_to_persona and not is_fulfiller_and_funder_same_person:
                    bounty_feedback(bounty, 'fulfiller', previous_bounties)

            # send email to the funder
            previous_bounties = Bounty.objects.filter(
                idx_status__in=statues,
                bounty_owner_email=submitter_email,
                current_bounty=True).exclude(pk=bounty.pk).distinct()
            has_been_sent_before_to_persona = previous_bounties.count()
            if not has_been_sent_before_to_persona and not is_fulfiller_and_funder_same_person:
                bounty_feedback(bounty, 'funder', previous_bounties)
Пример #3
0
    def handle(self, *args, **options):
        if settings.DEBUG:
            print("not active in non prod environments")
            return

        start_time = timezone.now() - timezone.timedelta(hours=36)
        end_time = timezone.now() - timezone.timedelta(hours=12)
        statues = ['done']
        bounties_fulfilled_last_timeperiod = Bounty.objects.filter(
            fulfillment_accepted_on__gt=start_time,
            fulfillment_accepted_on__lt=end_time,
            idx_status__in=statues)
        print(bounties_fulfilled_last_timeperiod.count())
        for bounty in bounties_fulfilled_last_timeperiod:

            # send email to the submitter
            submitter_email = bounty.bounty_owner_email
            previous_bounties = Bounty.objects.filter(
                web3_created__lt=bounty.web3_created,
                idx_status__in=statues,
                bounty_owner_email=submitter_email,
                current_bounty=True).exclude(pk=bounty.pk).distinct()
            has_been_sent_before_to_persona = previous_bounties.count()
            if not has_been_sent_before_to_persona:
                bounty_feedback(bounty, 'submitter', previous_bounties)

            # send email to the funder
            accepted_fulfillments = bounty.fulfillments.filter(accepted=True)
            if accepted_fulfillments.exists():
                accepted_fulfillment = accepted_fulfillments.first()
                fulfiller_email = accepted_fulfillment.fulfiller_email
                fulfillment_pks = BountyFulfillment.objects.filter(
                    accepted=True,
                    fulfiller_email=fulfiller_email).values_list('pk',
                                                                 flat=True)
                previous_bounties = Bounty.objects.filter(
                    web3_created__lt=bounty.web3_created,
                    idx_status__in=statues,
                    fulfillments__pk__in=fulfillment_pks,
                    current_bounty=True).exclude(pk=bounty.pk).distinct()
                has_been_sent_before_to_persona = previous_bounties.count()
                if not has_been_sent_before_to_persona:
                    bounty_feedback(bounty, 'funder', previous_bounties)
Пример #4
0
    def handle(self, *args, **options):
        start_time = timezone.now() - timezone.timedelta(hours=48)
        end_time = timezone.now() - timezone.timedelta(hours=24)
        statues = ['done']
        bounties_last_timeperiod = Bounty.objects.filter(
            modified_on__gt=start_time,
            modified_on__lt=end_time,
            idx_status__in=statues)
        print(bounties_last_timeperiod.count())
        for bounty in bounties_last_timeperiod:

            submitter_email = bounty.bounty_owner_email
            previous_bounties = Bounty.objects.filter(
                modified_on__lt=start_time,
                idx_status__in=statues,
                bounty_owner_email=submitter_email,
                current_bounty=True).exclude(pk=bounty.pk).distinct()
            has_been_sent_before_to_persona = previous_bounties.count()
            if not has_been_sent_before_to_persona:
                bounty_feedback(bounty, 'submitter', previous_bounties)

            accepted_fulfillments = bounty.fulfillments.filter(accepted=True)
            if accepted_fulfillments.exists():
                accepted_fulfillment = accepted_fulfillments.first()
                fulfiller_email = accepted_fulfillment.fulfiller_email
                fulfillment_pks = BountyFulfillment.objects.filter(
                    accepted=True,
                    fulfiller_email=fulfiller_email).values__list('pk',
                                                                  flat=True)
                previous_bounties = Bounty.objects.filter(
                    modified_on__gt=start_time,
                    idx_status__in=statues,
                    fulfillments__pk__in=fulfillment_pks,
                    current_bounty=True).exclude(pk=bounty.pk).distinct()
                has_been_sent_before_to_persona = previous_bounties.count()
                if not has_been_sent_before_to_persona:
                    bounty_feedback(bounty, 'funder', previous_bounties)