Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2036
TODO
Visits count is tracked via apreFlush
event listener. This is usually fine as long as the short URL existed before the visit, but in certain cases this is not true, like in tests, where we have to remember flushing short URLs before visits, or when importing short URLs.This can be solved by using a combination of
onFlush
to track the entities to be created +postFlush
, where those will have IDs. For some reason, when I first checked this I oversaw the existence of these events.Try to find a native way to do upserts in MS SQL and SQLite which does not require a select followed by an insert or update.I tried using a
MERGE
statement, but it ended up running un race conditions with duplicate keys due to not properly locking rows. See https://www.mssqltips.com/sqlservertip/3074/use-caution-with-sql-servers-merge-statement/?utm_source=AaronBertrandExisting SELECT then INSERT or UPDATE approach works better.
Sometimes API test covering short URLs lists fail when ordering by title.This is already happening with non-postgres engines in
develop
branch. It was just found at this moment because I tried to run API tests with the other engines.ShortUrlVisitsCountTracker
Next steps
ShortUrlVisitsCountTracker