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

Singleton sync and chip loader #63

Merged
merged 18 commits into from
Nov 1, 2024

Conversation

mattcarter11
Copy link
Contributor

@mattcarter11 mattcarter11 commented Oct 10, 2024

Feature / Changes

  • Include user uploaded songs, albums
  • Make syncing of songs, albums, playlists, artist faster and only allow one sync to run (singleton like)
  • Show loading spinner in:
    • Chip when syncing the showed data
    • Liked playlist
  • Add a Downloads chip in all old view. This shows albums, artists, playlist that have one or more downloaded song
    • songs now have a dateDownload
    • Fetching of download entities with downloads, ... is purely SQL now = better performance
  • Show N download/M songs in playlists/albums/artists
  • migrate SongByArtistAsc logic to SQL to improve performance
  • Break up DatabaseDao into smaller interfaces to improve development
  • Concentrated some SQL selects into one function to centralize code and remove duplicate logic

Sync spinner in chips and liked playlist

New Download chip (show only playlists/arts with any downloaded song)

N/M songs

Fixes

  • Fix sort ByPlayCountAsc using count instead of sum

@mattcarter11 mattcarter11 changed the title Singelton sync and chip loader [WIP] Singelton sync and chip loader Oct 10, 2024
@mattcarter11 mattcarter11 changed the title [WIP] Singelton sync and chip loader [WIP] Singleton sync and chip loader Oct 10, 2024
@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from e832cac to fc1c7ce Compare October 13, 2024 17:22
- Make sync of songs, albums, playlists, arits faster (corutines) and only run as "singletons"
- Rename some functions
@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from 58fe56b to 78e6ca0 Compare October 13, 2024 19:34
@mattcarter11
Copy link
Contributor Author

@mikooomich this one has some big files 😅 if anything has to change, I'm more than happy to oblige

@mikooomich
Copy link
Collaborator

As in a "this is ready for merge" or suggestions in general? I haven't looked into it too deeply, but looks great so far! A few things I noticed

  • App crashes on database migration. You probably can just let auto migration handle it (you basically don't have to do anything for simple field additions), and onPostUpgrade() if necessary. The manual migrations are only really necessary for when auto migrations won't cut it
  • On old layout (maybe new too?), switching tabs causes sync(?) even when auto sync is disabled

@mattcarter11
Copy link
Contributor Author

@mikooomich db migration removed and fixed the ytmSync being ignored in the playlist tab

@mattcarter11
Copy link
Contributor Author

mattcarter11 commented Oct 16, 2024

@mikooomich also, what do you think about adding this? A n/m download count on playlists/artists/albums with any downloaded song.

Maybe add an option to toggle this?

@mikooomich
Copy link
Collaborator

You cannot modify old db schema like that. You still need to increment db version and specify a database auto migration, see here -> c3e2ea7#diff-841cb2099b74da4d913f1cf1d60c554d9e6ae0dc6f8c3a22ad3b95a4b5b39568R107

A n/m download count on playlists/artists/albums with any downloaded song. Maybe add an option to toggle this?

Yeah, nice touch

If the pull request is wip could you mark it as such (with the selector), then mark it ready when its ready to be reviewed/merged

@mattcarter11 mattcarter11 marked this pull request as draft October 16, 2024 21:16
@mattcarter11 mattcarter11 changed the title [WIP] Singleton sync and chip loader Singleton sync and chip loader Oct 16, 2024
@mattcarter11 mattcarter11 marked this pull request as ready for review October 17, 2024 21:30
@mattcarter11
Copy link
Contributor Author

@mikooomich change done and added N/M songs

Copy link
Collaborator

@mikooomich mikooomich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello. A few nitpicks, otherwise, looks great.

For commits, mostly for sakes of readability/traceability:

  • Please remove merge commit(s). PRs should be rebased on conflict, or left as-is
  • Remove any rebase fixup commits (those should be applied within commits themselves)
  • Squash any duplicates ex. "fix sort lined song"
  • All database schema should be contained within one commit. It's just the one change with SongEntity, right? All the json modifications, adding migration, etc can probably go into one commit
  • Tagging. You can leave this PR as is, however in the future, we'd very much prefer commits to be tagged according to functionality/category. ex "ui: ..." "syncutils: ...", etc. It just makes searching/skimming/grouping much easier

Download icon is misaligned
image

NPE crash when clicking on albums

 FATAL EXCEPTION: main
                                                                                                    Process: com.dd3boh.outertunepr63, PID: 4785
                                                                                                    java.lang.NullPointerException: Parameter specified as non-null is null: method androidx.room.RoomSQLiteQuery.bindString, parameter value
                                                                                                    	at androidx.room.RoomSQLiteQuery.bindString(Unknown Source:2)
                                                                                                    	at com.dd3boh.outertune.db.DatabaseDao_Impl.__fetchRelationshipartistAscomDd3bohOutertuneDbEntitiesArtistEntity_1(DatabaseDao_Impl.java:12905)
                                                                                                    	at com.dd3boh.outertune.db.DatabaseDao_Impl.-$$Nest$m__fetchRelationshipartistAscomDd3bohOutertuneDbEntitiesArtistEntity_1(Unknown Source:0)
                                                                                                    	at com.dd3boh.outertune.db.DatabaseDao_Impl$97.call(DatabaseDao_Impl.java:7750)
                                                                                                    	at com.dd3boh.outertune.db.DatabaseDao_Impl$97.call(DatabaseDao_Impl.java:7717)
                                                                                                    	at androidx.room.CoroutinesRoom$Companion$createFlow$1$1$1.invokeSuspend(CoroutinesRoom.kt:129)
                                                                                                    	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
                                                                                                    	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                                                                                                    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                                                                                                    	at java.lang.Thread.run(Thread.java:1012)
                                                                                                    	Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@b352779, Dispatchers.Main.immediate]
2024-10-20 13:01:55.637  4785-4785  Process                 com.dd3boh.outertunepr63             I  Sending signal. PID: 4785 SIG: 9

@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch 8 times, most recently from a9eb829 to 225dfd7 Compare October 21, 2024 20:45
@mattcarter11
Copy link
Contributor Author

mattcarter11 commented Oct 21, 2024

@mikooomich

  • resolved all comments

  • merge removed

  • Squash some commits

  • alignment fixed

  • NPE crash when clicking on albums -> fixed (missing group by album.id)

  • All database schema should be contained within one commit -> should i squash commits? what if they are mixed with other stuff?

  • Remove any rebase fixup commits (those should be applied within commits themselves) -> what do you mean applied within commits themselves? the commits from the branch used to rebas (dev)?

@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch 2 times, most recently from c6f5a7f to 45afede Compare October 21, 2024 20:53
@mikooomich
Copy link
Collaborator

All database schema should be contained within one commit -> should i squash commits? what if they are mixed with other stuff?

"migrate get download logic to SQL (+performance) and add isDownload to song table"
For this, i'd seperate the rest of the sql stuff (another commit) and add is downloaded (one commit) . When you add the isdownloaded field, it comes it side effects: you need to handle migration and room will generate the json for db V16. that should all be contained in that commit.

This also means squash the following since into that commit since that will be handled in the commit you add isdownloaded

  • remove db migration
  • add new versiondb file
  • re-add migration since auto was failing
  • revert 15.json changes
  • and any more i'm missing (?)

Remove any rebase fixup commits (those should be applied within commits themselves) -> what do you mean applied within commits themselves? the commits from the branch used to rebas (dev)?

"add missing import after rebase" should not be its own commit (unless it's alot of fixing and makes sense to otherwise), instead, add it into the commit that needs it. (if you don't know where it came from, honestly you can just leave it as it)

@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from b0099a1 to ba57278 Compare October 30, 2024 17:55
- Add loading in chips tokens when syncing that token
- Add library and download chips in playlists
@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch 9 times, most recently from b07fcd7 to a8c8f98 Compare October 30, 2024 18:38
@mattcarter11 mattcarter11 force-pushed the singelton-sync-and-chip-loader branch from a8c8f98 to be50fd6 Compare October 30, 2024 18:40
@mattcarter11
Copy link
Contributor Author

@mikooomich changes done

@mikooomich mikooomich merged commit 24269a5 into DD3Boh:dev Nov 1, 2024
1 check passed
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.

2 participants