Support storing how many plays media has and other database improvements#1059
Merged
Conversation
We don't use these columns and won't in the foreseeable future. Query speed seems be to be faster now that we aren't filtering for the extra deleted_at cols.
…to FULL (did this work a long time ago now so commits are in weird order)
… is running to keep it running best
…ddActivity() and some formatting
it isn't used and is only a way for others to potentially add activity to other peoples watched entries since user owning the watched entry is not validated on the endpoint. Co-Authored-By: Dreddy <24421368+dredsen@users.noreply.github.com>
…text search for LastFinished sort
soz did this so long ago
Having the changelog file is one more step to no vendor lock-in. It's also more easily searched through and in a standard format everyone is probably used to. Just so you know, this was painful and I wanted nothing but death for myself throughout this whole process.
…ng with the .db file since v3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Changes
Changes made in this PR as they are shown in the CHANGELOG.
Data migrations
This is the first time migrations are being taken place when updating Watcharr, please be mindful of that and ensure you have your existing database backed up incase of any errors.
Backfilling
playsdata from users Activity.This migration was added so that existing data could be used to fill out how many plays of your media you have. It can't be 100% accurate because it has to make some assumptions, but it can get close and saves you a lot of time.
Dropping
deleted_atcolumns forwatched_seasonsandwatched_episodestables since we do not use them.I noticed that queries (eg for loading your main list) would take an extra ~100ms because we were adding a
deleted_at IS NULLto them when getting watched seasons/episodes. We don't use the deleted_at column, so I have just removed it from the tables (and queries so we have the speed boost).Moving to using WAL journal_mode for our sqlite database, which will grant us improvements in all areas.
Most database operations will be much faster now and more concurrent use of the database is now possible.
Important Note About Backups
You will notice that the database now comprises of three files:
watcharr.db(which has always been there) andwatcharr.db-wal,watcharr.db-shm(which are new).If you backup your database by copying the .db file (while your server is stopped of course), you should also copy the
watcharr.db-walfile since it can contain database content. You can ignore thewatcharr.db-shmfile if you want.Added
CountAsPlayproperty for tracking media total plays (this will speed up counting plays since we'll no longer rely on text searches in the db).0plays when they already have data we can use to get their total plays.Playsin WatchedDto where used.playscount for media inMyReviewcomponent.Changed
Fixed
Removed
deleted_atcolumns for watched episode/season tables.AddActivity(POST /activity) endpoint (Thanks [@Dredsen] for pointing out the flaw).Documentation
watcharr.db-walshould be backed up along with the .db file since v3.