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

decreaseses the login from from 7s to 2.3s by making the sync_profile tasks happen on a delay #7652

Merged
merged 7 commits into from
Oct 12, 2020
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
2 changes: 1 addition & 1 deletion app/app/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ def save_profile(backend, user, response, request, *args, **kwargs):
if not user.is_active:
raise SuspiciousOperation('You cannot login')

sync_profile(handle, user, hide_profile=False)
sync_profile(handle, user, hide_profile=False, delay_okay=True)
setup_lang(request, user)
6 changes: 5 additions & 1 deletion app/app/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,11 @@
path('_administration/email/gdpr_reconsent', retail.emails.gdpr_reconsent, name='gdpr_reconsent'),
path('_administration/email/share_bounty', retail.emails.share_bounty, name='share_bounty'),
path('_administration/email/new_tip/resend', retail.emails.resend_new_tip, name='resend_new_tip'),
path('_administration/email/tribe_hackathon_prizes', retail.emails.tribe_hackathon_prizes, name='tribe_hackathon_prizes'),
path(
'_administration/email/tribe_hackathon_prizes',
retail.emails.tribe_hackathon_prizes,
name='tribe_hackathon_prizes'
),
path(
'_administration/email/day_email_campaign/<int:day>',
marketing.views.day_email_campaign,
Expand Down
16 changes: 15 additions & 1 deletion app/app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,21 @@ def get_upload_filename(instance, filename):
return f"docs/{getattr(instance, '_path', '')}/{salt}/{file_path}"


def sync_profile(handle, user=None, hide_profile=True):
def sync_profile(handle, user=None, hide_profile=True, delay_okay=False):
from dashboard.models import Profile
handle = handle.strip().replace('@', '').lower()
profile = Profile.objects.filter(handle=handle).exists()
# cant sync_profile if profile not existing, especially if profile is needed for login
delay = delay_okay and profile
if delay:
from dashboard.tasks import sync_profile as sync_profile_task
user_pk = user.pk if user else None
sync_profile_task.delay(handle, user_pk, hide_profile)
else:
actually_sync_profile(handle, user=user, hide_profile=hide_profile)


def actually_sync_profile(handle, user=None, hide_profile=True):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

many of the chat related tasks here could be done on a delay as well; a further PR would possibly do that so that upon first login were not blocking on things like chat tasks to create the profile

from dashboard.models import Profile
handle = handle.strip().replace('@', '').lower()
# data = get_user(handle, scoped=True)
Expand Down
26 changes: 14 additions & 12 deletions app/assets/v2/css/town_square.css
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,20 @@ body.green.offer_view .announce {
color: var(--townsquare-block-header-color);
}

.dark-mode .modal-content .btn-radio,
.dark-mode .modal-content .close,
.dark-mode .vs__search,
.dark-mode .vs__selected,
.dark-mode .vs__dropdown-option,
.dark-mode .vs__search:focus {
color: var(--default-text-color);
}

.dark-mode .modal-content .btn-radio:hover {
color: var(--default-text-color);
}


#status .btn-group-toggle .btn-radio {
background-color: var(--badge-blue-bg);
color: var(--badge-blue-text);
Expand Down Expand Up @@ -1352,14 +1366,6 @@ body.green.offer_view .announce {
color: var(--default-text-color);
}

.dark-mode .modal-content .btn-radio,
.dark-mode .modal-content .close,
.dark-mode .vs__search,
.dark-mode .vs__selected,
.dark-mode .vs__dropdown-option,
.dark-mode .vs__search:focus {
color: var(--default-text-color);
}
.dark-mode .vs__dropdown-toggle {
border-color: var(--default-text-color);
}
Expand All @@ -1369,10 +1375,6 @@ body.green.offer_view .announce {
fill: var(--default-text-color);
}

.dark-mode .modal-content .btn-radio:hover {
color: var(--default-text-color);
}

.dark-mode .display-light {
display: none;
}
Expand Down
8 changes: 8 additions & 0 deletions app/dashboard/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,11 @@ def increment_view_count(self, pks, content_type, user_id, view_type, retry: boo
)
except:
pass # fix for https://sentry.io/organizations/gitcoin/issues/1715509732/


@app.shared_task(bind=True, max_retries=1)
def sync_profile(self, handle, user_pk, hide_profile, retry: bool = True) -> None:
from app.utils import actually_sync_profile
from django.contrib.auth.models import User
user = User.objects.filter(pk=user_pk).first() if user_pk else None
actually_sync_profile(handle, user=user, hide_profile=hide_profile)
5 changes: 4 additions & 1 deletion app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,10 @@ def build_grants_by_type(request, grant_type='', sort='weighted_shuffle', networ
if 'match_pledge_amount_' in sort:
sort_by_clr_pledge_matching_amount = int(sort.split('amount_')[1])
if sort in ['-amount_received_in_round', '-clr_prediction_curve__0__1']:
_grants = _grants.filter(is_clr_active=True)
grant_type_obj = GrantType.objects.filter(name=grant_type).first()
is_there_a_clr_round_active_for_this_grant_type_now = grant_type_obj and grant_type_obj.active_clrs.exists()
if is_there_a_clr_round_active_for_this_grant_type_now:
_grants = _grants.filter(is_clr_active=True)

if omit_my_grants and profile:
grants_id = list(profile.grant_teams.all().values_list('pk', flat=True)) + \
Expand Down
7 changes: 5 additions & 2 deletions app/marketing/mails.py
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,9 @@ def grant_match_distribution_test_txn(match):

We will be issuing a final payout transaction in DAI within 24-72 hours of this email. No action is needed on your part, we will issue the final payout transaction automatically.

If you're looking to kill time before your payout is administered.... {coupon}
If you're looking to kill time before your payout is administered....
1. Please fill out this 2 min Gitcoin Grants survey [https://gitcoin.typeform.com/to/fWNIwxSR]. We'd love to hear how the round went for you.
2. {coupon}

Thanks,
Kevin, Scott, Vivek & the Gitcoin Community
Expand Down Expand Up @@ -1171,7 +1173,8 @@ def grant_match_distribution_final_txn(match):
What now?
1. Send a thank you tweet to the public goods justice league (who funded this round) on twitter: @balancerlabs @synthetix_io @iearnfinance @optimismpbc @chainlink @defiancecapital . Here is a handy one click link: https://twitter.com/intent/tweet?text=@balancerlabs+@synthetix_io+@iearnfinance+@optimismpbc+@chainlink+@defiancecapital+thank+you+for+funding+gitcoin+grants!
2. Remember to update your grantees on what you use the funds for by clicking through to your grant ( https://gitcoin.co{match.grant.get_absolute_url()} ) and posting to your activity feed.
3. Celebrate 🎉 and then get back to BUIDLing something great. 🛠
3. Celebrate 🎉 and consider joining us for KERNEL 2 ( https://gitcoin.co/blog/announcing-kernel-block-2/ ) as you continue growing your project. 🛠🛠
4. Please fill out this 2 min Gitcoin Grants survey [https://gitcoin.typeform.com/to/fWNIwxSR]. We'd love to hear how the round went for you.

Thanks,
Kevin, Scott, Vivek & the Gitcoin Community
Expand Down
11 changes: 11 additions & 0 deletions docs/user_directory.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Running User Directory Elastic Search locally

Elastic Search will automatically start up on `docker-compose up`
Additional configuration options are available in the elasticsearch.yml file.

*Setup Steps*

1. Install the Materialized View in your database. (<https://gist.github.com/danlipert/8604040ca8f1163f29d7e841fd3a54fb>)
2. Add an ENV for the HAYSTACK_ELASTIC_SEARCH_URL variable to your app/app/.env file, `HAYSTACK_ELASTIC_SEARCH_URL=http://elasticsearch:9200`
3. Restart Gitcoin Web with updated env variables
4. Execute the management command rebuild_index and select Y when asked if you want to destroy your index. `docker-compose exec web app/manage.py rebuild_index`