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

Search alerts / saved searches #2113

Open
actlikewill opened this issue Oct 23, 2024 · 1 comment · May be fixed by #2161
Open

Search alerts / saved searches #2113

actlikewill opened this issue Oct 23, 2024 · 1 comment · May be fixed by #2161
Assignees
Labels
discovery search and discovery impact: medium okr okr key result

Comments

@actlikewill
Copy link
Contributor

actlikewill commented Oct 23, 2024

Users should be able to save some of their commonly repeated searches and be able to perform the same search with a single click. This feature will be most useful if it is quick and easliy accessible. While searching, users can be prompted to save a search in a non-intrusive manner, and still while searching, users can be prompted to bring up a saved search. Users should be able to view and remove previously saved searches.

Proposal

UX

Search page

When a user performs a search we show a "Subscribe" button in a box above the search results prompting them to subscribe to alerts for this search when new content is added.

If the user clicks on the button:

  • if the user is logged in, it creates a new search alert and the box updates to reflect that the alert is saved, and has a link to "manage your search alerts" which takes them to the search alerts page.
  • if the user is not logged in, it opens a "sign in or subscribe" modal (much like for saving documents) that then sends the user back to this page once they are signed in.

Search alerts page
Users should be able to access their search alerts through a "Search Alerts" listing page.
The page will display saved searches in a list view, sorted by date, showing:

  • Search term.
  • Date saved.
  • Any note added by the user.
    Users can:
  • Re-run any saved search with a single click.
  • Delete any saved search they no longer need.

Implementation

Add a new SavedSearch model with the following fields:

   q = models.CharField(max_length=4098)  # The primary search term(s).
   filters = models.CharField(max_length=4098)  # string or parameters for any filters/criteria.
   note = models.TextField(null=True, blank=True)  # additional notes that user wants to add.
   n_search_results = models.IntegerField(default=0)  # Number of results returned when initially saved.
   user = models.ForeignKey(User, on_delete=models.CASCADE)  # Link to the user who saved the search.
   date = models.DateField(auto_now_add=True)  # Automatically set the date when a search is saved.

Search results page

  • On the search results page add a small prompt (e.g. alert box) to ask if they’d like to save the search.
  • If they click "Save," open a dialog allowing them to confirm and optionally add a note.

Saved searches page

Create a dedicated page with a simple list view for saved searches, displaying:

  • Date saved.
  • Search term.
  • Number of results (optional).
  • Note (if any).
    Each entry should have:
  • A "Run" button to execute the saved search.
  • A "Delete" button for removal.
    Use HTMX for a smooth deletion experience without reloading the page.

Save Search API Endpoint

Add a drf API endpoint to handle saving searches with relevant data (POST request):
It should accept the search term, filter_parameters, note, user, and number of results.

@actlikewill actlikewill added the write-up Write-up required label Oct 23, 2024
@actlikewill actlikewill removed their assignment Nov 5, 2024
@actlikewill actlikewill removed the write-up Write-up required label Nov 7, 2024
@longhotsummer longhotsummer added discovery search and discovery impact: medium okr okr key result labels Nov 7, 2024
@longhotsummer longhotsummer changed the title Saved searches Search alerts / saved searches Nov 7, 2024
@longhotsummer
Copy link
Contributor

longhotsummer commented Nov 7, 2024

New pages and URLs

Search page

When a search is run, the Vue search app puts the search alert box into the page and uses HTMX (ajax?) to load the content of the box. This allows the server to check if a search alert for this search already exists.

  • GET /search/saved-searches/check?q=... renders the search alert box, customised if the user is logged in and if they have already saved this search

If the user is not logged in, that html has a normal bootstrap modal with the login prompt, no special HTMX or JS needed.

If the user is logged in, and they have not saved this search, the button is part of a form which POSTs to a new endpoint that is submitted with HTMX and the box is updated with the text for a newly created saved search alert.

  • POST /search/saved-searches

If the user is logged in and they have saved this search before, the box has an Unsubscribe experience that deletes the saved search.

  • POST /search/saved-searches/<pk>/delete

Search alerts page

The search alert listing page also doubles as a detail page. It is part of the user profile page.

A search alert can be deleted by posting to the same deletion endpoint as above.

Clicking on a search alert opens the search page with all the details filled in.

@actlikewill actlikewill linked a pull request Nov 15, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discovery search and discovery impact: medium okr okr key result
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants