예제 #1
0
 def handle(self, *args, **options):
     if settings.DEBUG:
         print("not active in non prod environments")
         return
     hours_back = 24
     eses = EmailSubscriber.objects.filter(active=True)
     print("got {} emails".format(eses.count()))
     for es in eses:
         try:
             keywords = es.keywords
             if not keywords:
                 continue
             to_email = es.email
             new_bounties, all_bounties = get_bounties_for_keywords(
                 keywords, hours_back)
             print("{}/{}: got {} new bounties & {} all bounties".format(
                 to_email, keywords, new_bounties.count(),
                 all_bounties.count()))
             if new_bounties.count():
                 print(f"sending to {to_email}")
                 new_bounty_daily(new_bounties, all_bounties, [to_email])
                 print(f"/sent to {to_email}")
         except Exception as e:
             logging.exception(e)
             print(e)
예제 #2
0
 def handle(self, *args, **options):
     if settings.DEBUG:
         print("not active in non prod environments")
         return
     hours_back = 24
     eses = EmailSubscriber.objects.filter(active=True)
     counter_grant_total = 0
     counter_total = 0
     counter_sent = 0
     print("got {} emails".format(eses.count()))
     for es in eses:
         try:
             counter_grant_total += 1
             to_email = es.email
             keywords = es.keywords
             town_square_enabled = is_email_townsquare_enabled(to_email)
             should_eval = keywords or town_square_enabled
             if not should_eval:
                 continue
             counter_total += 1
             new_bounties, all_bounties = get_bounties_for_keywords(keywords, hours_back)
             print("{}/{}/{}) {}/{}: got {} new bounties & {} all bounties".format(counter_sent, counter_total, counter_grant_total, to_email, keywords, new_bounties.count(), all_bounties.count()))
             should_send = new_bounties.count() or town_square_enabled
             if should_send:
                 print(f"sending to {to_email}")
                 new_bounty_daily(new_bounties, all_bounties, [to_email])
                 print(f"/sent to {to_email}")
                 counter_sent += 1
         except Exception as e:
             logging.exception(e)
             print(e)
예제 #3
0
    def handle(self, *args, **options):
        if settings.DEBUG and not override_in_dev:
            print("not active in non prod environments")
            return
        hours_back = 24
        eses = EmailSubscriber.objects.filter(
            active=True).distinct('email').order_by('-email')
        counter_eval_total = 0
        counter_total = 0
        counter_sent = 0
        start_time = time.time()
        total_count = eses.count()
        print("got {} emails".format(total_count))
        for es in eses:
            try:
                counter_eval_total += 1
                if should_suppress_notification_email(
                        es.email, 'new_bounty_notifications'):
                    continue
                # prep
                now = timezone.now()
                to_email = es.email
                keywords = es.keywords
                town_square_enabled = is_email_townsquare_enabled(to_email)
                should_eval = keywords or town_square_enabled
                if not should_eval:
                    continue
                if not validate_email(to_email):
                    continue
                counter_total += 1
                new_bounties, all_bounties = get_bounties_for_keywords(
                    keywords, hours_back)
                featured_bounties = Bounty.objects.current().filter(
                    network='mainnet', idx_status='open',
                    expires_date__gt=now).order_by(
                        'metadata__hyper_tweet_counter')[:2]

                # stats
                speed = round((time.time() - start_time) / counter_eval_total,
                              2)
                ETA = round((total_count - counter_eval_total) / speed / 3600,
                            1)
                print(
                    f"{counter_sent} sent/{counter_total} enabled/{counter_eval_total} evaluated, {speed}/s, ETA:{ETA}h, working on {to_email} "
                )

                # send
                should_send = new_bounties.count() or town_square_enabled
                #should_send = new_bounties.count()
                if should_send:
                    #print(f"sending to {to_email}")
                    new_bounty_daily(new_bounties, all_bounties, [to_email],
                                     featured_bounties)
                    #print(f"/sent to {to_email}")
                    counter_sent += 1
            except Exception as e:
                logging.exception(e)
                print(e)
예제 #4
0
    def handle(self, *args, **options):
        if settings.DEBUG and not override_in_dev:
            print("not active in non prod environments")
            return
        hours_back = 24
        eses = EmailSubscriber.objects.filter(active=True).distinct('email')
        counter_grant_total = 0
        counter_total = 0
        counter_sent = 0
        start_time = time.time()
        total_count = eses.count()
        print("got {} emails".format(total_count))
        for es in eses:
            try:
                # prep
                counter_grant_total += 1
                to_email = es.email
                keywords = es.keywords
                town_square_enabled = is_email_townsquare_enabled(to_email)
                should_eval = keywords or town_square_enabled
                if not should_eval:
                    continue
                if not validate_email(to_email):
                    continue
                counter_total += 1
                new_bounties, all_bounties = get_bounties_for_keywords(keywords, hours_back)

                # stats
                speed = round((time.time() - start_time) / counter_grant_total, 2)
                ETA = round((total_count - counter_grant_total) / speed / 3600, 1)
                print(f"{counter_sent} sent/{counter_total} enabled/{counter_grant_total} evaluated, {speed}/s, ETA:{ETA}h, working on {to_email} ")

                # send
                should_send = new_bounties.count() or town_square_enabled
                #should_send = new_bounties.count()
                if should_send:
                    #print(f"sending to {to_email}")
                    new_bounty_daily(new_bounties, all_bounties, [to_email])
                    #print(f"/sent to {to_email}")
                    counter_sent += 1
            except Exception as e:
                logging.exception(e)
                print(e)