Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu committed Sep 4, 2020
2 parents 103d196 + 416e458 commit b29a906
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 19 deletions.
7 changes: 4 additions & 3 deletions app/kudos/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,10 @@ def redeem_bulk_kudos(self, kt_id, retry=False):
multiplier = 1
# high gas prices, 5 hour gas limit - DL
gas_price = int(float(recommend_min_gas_price_to_confirm_in_time(300)) * multiplier)
if gas_price > delay_if_gas_prices_gt_redeem and self.request.retries < self.max_retries:

self.retry(countdown=60*10)
if gas_price > delay_if_gas_prices_gt_redeem:
# do not retry is gas prices are too high
# TODO: revisit this when gas prices go down
# self.retry(countdown=60*10)
return

obj = KudosTransfer.objects.get(pk=kt_id)
Expand Down
15 changes: 9 additions & 6 deletions app/marketing/management/commands/new_bounties_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from dashboard.models import Bounty
from marketing.mails import new_bounty_daily
from marketing.models import EmailSubscriber
from marketing.utils import should_suppress_notification_email
from townsquare.utils import is_email_townsquare_enabled

warnings.filterwarnings("ignore")
Expand Down Expand Up @@ -74,18 +75,20 @@ def handle(self, *args, **options):
print("not active in non prod environments")
return
hours_back = 24
eses = EmailSubscriber.objects.filter(active=True).distinct('email')
counter_grant_total = 0
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()
counter_grant_total += 1
to_email = es.email
keywords = es.keywords
town_square_enabled = is_email_townsquare_enabled(to_email)
Expand All @@ -101,9 +104,9 @@ def handle(self, *args, **options):
expires_date__gt=now).order_by('metadata__hyper_tweet_counter')[:2]

# 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} ")
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
Expand Down
1 change: 0 additions & 1 deletion app/retail/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,6 @@ def render_new_bounty_roundup(to_email):
offset = 2
email_style = (int(timezone.now().strftime("%V")) + offset) % 7


intro = args.body
highlights = args.highlights
sponsor = args.sponsor
Expand Down
18 changes: 9 additions & 9 deletions app/retail/templates/emails/new_bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ <h3 class="no-subtitle" style="margin-top: 5px; margin-bottom: 5px;">{{email_ann
{% endif %}
{% if featured_bounties %}
<div style="margin-bottom: 5em;">
<h3 class="no-subtitle">{% trans "🏆 Featured bounties for you!" %}</h3>
<h3 class="no-subtitle">{% trans " Featured bounties for you!" %}</h3>

{% for bounty in featured_bounties %}
{% include 'emails/bounty.html' with bounty=bounty count=forloop.counter small=1%}
Expand All @@ -114,7 +114,7 @@ <h3 class="no-subtitle">{% trans "🏆 Featured bounties for you!" %}</h3>
{% endif %}
{% if chats_count %}

<h3 class="no-subtitle" style="margin-top: 15px;">💬 {{chats_count}} New Chat Messages</h3>
<h3 class="no-subtitle" style="margin-top: 15px;"> {{chats_count}} New Chat Messages</h3>

<p style="margin-bottom: 25px;">You have <a href="{{base_url}}{% url 'inbox:inbox_view' %}" style="font-weight: bold;">{{ chats_count }} unread chats</a>.Check them out</p>

Expand All @@ -129,7 +129,7 @@ <h3 class="no-subtitle" style="margin-top: 15px;">💬 {{chats_count}} New Chat

<div style="text-align: center;">
{% if notifications_count %}
<h3 class="no-subtitle" style="margin-top: 15px;">🔵 {{notifications_count}} Unread Notifications</h3>
<h3 class="no-subtitle" style="margin-top: 15px;"> {{notifications_count}} Unread Notifications</h3>

<p style="margin-bottom: 25px;">You have <a href="{{base_url}}{% url 'inbox:inbox_view' %}" style="font-weight: bold;">{{ notifications_count }} unread notifications</a>.Check them out</p>
<div style="margin-bottom: 2em; margin-top: 2em;">
Expand All @@ -141,7 +141,7 @@ <h3 class="no-subtitle" style="margin-top: 15px;">🔵 {{notifications_count}}


{% if activities %}
<h3 class="no-subtitle" style="margin-top: 15px;">{% trans "💬Town Square Posts You've Missed" %}</h3>
<h3 class="no-subtitle" style="margin-top: 15px;">{% trans "Town Square Posts You've Missed" %}</h3>
<div class="container" style="text-align: left; padding: 20px 10px">
<div class="col-12 col-md-10 col-lg-8 mx-auto">
{% include 'shared/activity_container.html' with hide_loading=1 for_email=1 %}
Expand Down Expand Up @@ -178,7 +178,7 @@ <h4 style="">{{event.title}}</h4>

{% if trending_avatar %}
<div style="margin-bottom: 5em;">
<h3 class="no-subtitle">{% trans "👤 Trending Avatar" %}: {{trending_avatar.humanized_name}}</h3>
<h3 class="no-subtitle">{% trans " Trending Avatar" %}: {{trending_avatar.humanized_name}}</h3>
<div style="margin-top: 25px; ">
<a href="{{trending_avatar.url}}">
<img src='{{trending_avatar.img_url}}' style="max-width: 200px; height: 200px; border-radius: 100px;">
Expand All @@ -192,7 +192,7 @@ <h3 class="no-subtitle">{% trans "👤 Trending Avatar" %}: {{trending_avatar.hu
<HR>
{% endif %}
{% if quest_of_the_day %}
<h3 class="no-subtitle" style="margin-top: 50px">{% trans "🎯Quest of The Day" %}</h3>
<h3 class="no-subtitle" style="margin-top: 50px">{% trans "Quest of The Day" %}</h3>
{% include 'emails/quest_small.html' with quest=quest_of_the_day small=1 %}
{% endif %}

Expand All @@ -202,7 +202,7 @@ <h3 class="no-subtitle" style="margin-top: 50px">{% trans "🎯Quest of The Day"

{% if show_action %}

<h3 class="no-subtitle" style="margin-top: 15px;">{% trans "🌈1 New Daily Action" %}</h3>
<h3 class="no-subtitle" style="margin-top: 15px;">{% trans "1 New Daily Action" %}</h3>

<a href={{base_url}}>
<img style="width: 306px; height: 80px; margin-top: 5px; margin-bottom: 5px;" src={{base_url}}static/v2/images/offer.gif>
Expand All @@ -214,15 +214,15 @@ <h3 class="no-subtitle" style="margin-top: 15px;">{% trans "🌈1 New Daily Acti

<HR>
{% else %}
<h3 class="no-subtitle" style="margin-top: 15px;">{% trans "🌈0 New Daily Action" %}</h3>
<h3 class="no-subtitle" style="margin-top: 15px;">{% trans "0 New Daily Action" %}</h3>
<a href={{base_url}}>
<img style="width: 306px; height: 80px; margin-top: 5px; margin-bottom: 5px;" src={{base_url}}static/v2/images/offer.gif>
</a>
{% endif %}

{% if bounties %}
<div style="margin-bottom: 5em;">
<h3 class="no-subtitle">{% trans "💰Start Earning!" %}</h3>
<h3 class="no-subtitle">{% trans "Start Earning!" %}</h3>

{% for bounty in bounties %}
{% include 'emails/bounty.html' with bounty=bounty count=forloop.counter small=1%}
Expand Down
28 changes: 28 additions & 0 deletions scripts/debug/remove_emoji.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""
Remove emoji from a text file and print it to stdout.
Usage
-----
python remove-emoji.py input.txt > output.txt
"""
import re
import sys

# https://stackoverflow.com/a/49146722/330558
def remove_emoji(string):
emoji_pattern = re.compile("["
u"\U0001F600-\U0001F64F" # emoticons
u"\U0001F300-\U0001F5FF" # symbols & pictographs
u"\U0001F680-\U0001F6FF" # transport & map symbols
u"\U0001F1E0-\U0001F1FF" # flags (iOS)
u"\U00002702-\U000027B0"
u"\U000024C2-\U0001F251"
"]+", flags=re.UNICODE)
return emoji_pattern.sub(r'', string)

if __name__ == '__main__':
text = open(sys.argv[1]).read()
text = remove_emoji(text)
print(text)

0 comments on commit b29a906

Please sign in to comment.