-
-
Notifications
You must be signed in to change notification settings - Fork 775
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
Feature: Show Recent People I've Tipped #7830
Feature: Show Recent People I've Tipped #7830
Conversation
@@ -462,6 +462,15 @@ def send_tip_2(request): | |||
user['avatar_url'] = profile.avatar_baseavatar_related.filter(active=True).first().avatar_url | |||
user['preferred_payout_address'] = profile.preferred_payout_address | |||
|
|||
recent_tips = Tip.objects.filter(sender_profile=request.user.profile).order_by('-created_on') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recent_tips_profiles = Profile.objects.filter(received_tips__in=Tip.objects.filter(sender_profile__id=7766)).order_by('-received_tips__created_on')
Unfortunately you can't use distinct here or it could be a one-liner! https://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct
Anyway, no need to change the code, but thought it was an interesting way to access the profiles directly..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I spent 1.5+ days only on trying to make this one query better and efficient. But couldn't find a way to make it a single query/one-liner. Tried several several several ways, but no use. That's a bummer
Another good one may look something like:
recent_tips_profiles = Tip.objects.filter(sender_profile=request.user.profile).distinct('recipient_profile').order_by('-created_on')
But it produces this error on Postgres:
ERROR: SELECT DISTINCT ON expressions must match initial ORDER BY expressions
I did find this: https://code.djangoproject.com/ticket/24218. But it's still new
.
Tried several other ways too. But had to settle with this in the end. 🤢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it really exposes where the ORM falls short, basically since you are joining tables then the rows are no longer distinct
yay! |
@sebastiantf this PR breaks the gitcoin.co/tip experience for a non logged in user. can u pls put in a follow up PR for that? |
@owocki I have a follow-up PR at #7938 Apologies for the issue |
Thanks Sebastian! |
Description
This PR adds a new feature that shows the list of users (max of 7) that you've recently tipped, when you visit http://gitcoin.co/tip
Refers/Fixes
Fixes #7681
Screenshots
GIF:
Video: https://www.loom.com/share/bdd437d9ea5245df9005173b90f0e9ab
Video: https://www.loom.com/share/cffb44d8cb8345fbb051b6edb50011bc
Screenshot:
Done: