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

Alerts for new documents for courts/judges/province/municipality/subject areas you’re interested in #2242

Open
niiroobiro opened this issue Jan 22, 2025 · 2 comments
Assignees
Labels
impact: high personalisation Relates to authenticated users Premium
Milestone

Comments

@niiroobiro
Copy link
Contributor

niiroobiro commented Jan 22, 2025

The idea behind this feature is that a user can indicate their interest in a variety of different things, and we'll notify them when a new document is added that is linked to that thing.

Conceptually, there are two aspects:

  1. the user can choose to follow (or unfollow) a thing
  2. we periodically check for documents with a "creation" date after the last alert was sent for the "thing", and send emails accordingly

Models that can be followed:

  • Author
  • Country (jurisdiction)
  • Locality
  • CourtClass
  • Court
  • CourtRegistry
  • TaxonomyTopic

More can readily be added later.

Proposal

UX

Following

On the detail page for each thing to be followed, a new button is added (bell) Follow XXX or (bell) Unfollow XXX.

The button is loaded dynamically by htmx just like the "save" button for documents, so that caching isn't impacted.

  • Endpoint: GET /account/following/button?taxonomy=10 (where the query params have the thing being followed and the PK

If the user is logged in, it checks if the user is following the thing and returns a follow or unfollow button as appropriate.

If the user is NOT logged in, it shows a follow button that shows the login modal (similar to search alerts).

Clicking the follow button sends a POST that sets up the following and redirects to the button url, to change the button to unfollow.

  • Endpoint: POST /account/following/follow?taxonomy=10
  • Endpoint: POST /account/following/unfollow?taxonomy=10

Because the buttons are standalone, we can later add them to any part of any page. For example, a judgment detail page could have a "Follow" button alongside the court name.

User profile

A new tab is added to the User profile page called "Following", that lists the things that the user is following, and includes an unfollow button. The behaviour of the button can be exactly the same as above. This would mean if the user accidentally unfollows, the entry is still there but now with a Follow button. If they refresh the page, it's gone.

  • Endpoint: GET /account/following

Emails

Sending one email per day reduces the number of emails sent. It could look a bit like this:

Dear Greg,

We've found new documents for areas that you're following.

High Court
----------

1. Foo
2. Bar
3. Baz

Education
---------

1. Boom
2. Baz

Manage what you're following (link)

Best,
The LII team

Backend

A new UserFollowing model:

  • user: FK
  • court: FK
  • taxonomy_topic: FK
  • etc (see below)
  • created_at: timestamp
  • last_alerted_at: timestamp

Each UserFollowing model is linked to a user, and one of a wide variety of things that can be followed. It's better to use explicit foreign keys rather than Django's generic foreign keys, because when we're checking for new documents we need to know exactly what we're checking for. It also means we know exactly what things can be followed.

A daily background task wakes up and queues up new background tasks for each user that has UserFollowing models. The task for each user:

  1. gathers all the documents that are new for each UserFollowing instance
  2. combines them into a single email, grouped by the thing being followed
  3. sends the email (if any)
  4. updates the last_alerted_at timestamp on each UserFollowing instance
@niiroobiro niiroobiro added the write-up Write-up required label Jan 22, 2025
@longhotsummer longhotsummer added this to the 2025-Q1 milestone Jan 22, 2025
@longhotsummer longhotsummer removed the write-up Write-up required label Jan 22, 2025
@longhotsummer
Copy link
Contributor

Ready for review!

@longhotsummer longhotsummer added the write-up Write-up required label Jan 22, 2025
@niiroobiro niiroobiro added personalisation Relates to authenticated users Premium labels Jan 28, 2025
@actlikewill
Copy link
Contributor

Looks good we can move to prioritized

@actlikewill actlikewill removed the write-up Write-up required label Jan 29, 2025
@longhotsummer longhotsummer removed their assignment Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
impact: high personalisation Relates to authenticated users Premium
Projects
None yet
Development

No branches or pull requests

4 participants