-
-
Notifications
You must be signed in to change notification settings - Fork 151
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
Do front end and API for Pray and Pay #4507
Comments
@mlissner, right now I'm thinking of doing the API first and allowing tech-savvy people to test the internals of the feature (does the leaderboard show the documents, etc.). Good points on the front end--I hadn't thought it through that deeply until seeing your post. I will take a bit to digest it before offering a new design. One thing that I've been thinking of, however, is whether it is beneficial to limit document requests to people with accounts. Do you have statistics for what fraction of the CourtListener DAU count signs in with an account? If we're limiting the feature to a small fraction of the user base, that seems counterproductive. |
One thing that helps a lot with getting front-end stuff in place is django-waffles. That will easily allow us to get something into prod that can only be used by a few select people. It really lowers the stress level.
A bit, perhaps, but I think the alternative is to use cookies on anonymous users, right? That is fine right now, but we're planning a CDN that would serve cached content to those without cookies, so I don't think I want to start using cookies on anonymous people just because of that. We do have a pretty good solution for this though, which is to prompt people to log in when they click something like this. Try loading a docket page while logged out and clicking the "Create Alert" button. You'll see this: We could easily trigger that modal on the prayer-hands emoji, and I think we'd get people logging in if they want to participate. Seems better than allowing anonymous trouble-makers! |
@mlissner I am making good progress on the front end. I was thinking of the following design.
My question for you: is this an impractical use of resources? Every unavailable document would need a database query to see if there are any open prayers for it. For a page with n docket entries, I suspect there are already 2n database queries (n for the text of the row, and another n for the documents themselves). This might turn that into 3n queries. |
Thanks @v-anne, this is getting close! I think I'd prefer a smaller button without the words, if we can pull it off. Maybe using a mouseover on desktop, and maybe just simply hidden on mobile? I think your various states seem pretty good. I think the "wait 24 hours" might be wrong though, because I think they'd get their next batch...when? At midnight UTC? I'm actually not sure, but I suspect it's not 24 hours? What do you think? |
Yeah, this is definitely possible, it could just be the 🙏 emoji, and then if there are open requests for that document, it could show something like "2 x 🙏"
I think the current function has a rolling limit, where it sees if 5 requests were made within the last 24 hours (not the last calendar day, but the last 24 hours), it stops the user from making another request until there are no longer 5 requests within the time limit. async def prayer_eligible(user: User) -> bool:
allowed_prayer_count = settings.ALLOWED_PRAYER_COUNT
now = timezone.now()
last_24_hours = now - timedelta(hours=24)
# Count the number of prayers made by this user in the last 24 hours
prayer_count = await Prayer.objects.filter(
user=user, date_created__gte=last_24_hours
).acount()
return prayer_count < allowed_prayer_count |
Yep! Maybe without the × even.
Yeah, that seems right, so we'll just want to tweak the language we show the user to something vague instead of the 24 hours thing. You also said, but I didn't catch, that you were going to put that in the https://getbootstrap.com/docs/4.0/components/tooltips/#examples |
I'm sorry, I was conflating the two. I intended to mean using the mouseover, just like you suggested, but I didn't realize there was a distinction between them. |
@mlissner can you add me to the waffle flag? |
Done. |
I'm experimenting with the feature now. I'm glad that we were able to push to production. I think the |
A few bits of quick reaction from me:
What else are others thinking/seeing? This is really cool. Now it's about polish! |
I heartily love waffles for anything UI-related. After another round of cleanup and documentation, we can do a social media post and get more people opted in. 🧇! |
Sorry, what do you mean by this? |
Try and click just inside the button to the right of the emoji. It doesn't work for me. |
Got it, I see it now. Not sure what's going on. |
A few more issues:
|
@v-anne I'm experimenting with this template. Here's my progress so far: |
@mlissner is the button clicking issue fixed now? I can't replicate it anymore. |
I'm thinking of taking this a step further. We can allow users to make their list of prayers public. That way journalists can share their lists with their readership and ask them to crowdsource documents they'd like to use for their work. |
Seems to be. Must have been related to the other JS problem.
Fun idea, but let's not add to our MVP requirements, and let's just see if we can get something out the door first? |
An earlier message has a nice prototype of how the front end could work:
Originally posted by @v-anne in #4486 (comment)
To do this, we'll need two things:
The API should probably use the Django Rest Framework. I think a good example for this would be
DocketAlertViewSet
, which is documented here:https://www.courtlistener.com/help/api/rest/alerts/#dockets
I don't think we need documentation for P&P.
For the front end, I think the picture above is good, but two thoughts off the bat:
I think the icon needs a few states:
I like how unobtrusive the icon is now, but it doesn't teach people what it is. Maybe a mouseover popup? Explaining or leading to a help page?
Another question is how people find the leaderboard. Ideally it'd somehow be tied to the button, I think, but I'm not sure how. Maybe it could also live in the mouseover popup.
We usually use HTMX for doing updates like these, if that's feasible.
Finally, with UI stuff, it's really nice and fairly easy to use django-waffle to launch it for just a few people at a time. I'd definitely recommend that for a feature this big.
The text was updated successfully, but these errors were encountered: