Skip to content

Conversation

@indykoning
Copy link
Member

This PR fixes the duplicate entry on search queries in 2 ways.

  1. Removing the middleware posting the search query on state change, there is already a listener on insights-event:viewedObjectIDs which does this and also adds the number of hits.
  2. Calling firstOrCreate instead of firstOrNew. While this would run an additional query in case the search term does not exist this already deals with UniqueConstraintViolationExceptions, returning the existing model from the database

This way even with bad timing it should not be possible to cause another UniqueConstraintViolationException

@indykoning indykoning requested a review from royduin as a code owner December 5, 2025 12:12
@royduin royduin requested a review from Jade-GG December 9, 2025 07:59
@royduin
Copy link
Member

royduin commented Dec 9, 2025

We also need this on master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants