swingmx / swingmusic

Swing Music is a beautiful, self-hosted music player for your local audio files. Like a cooler Spotify ... but bring your own music.
https://swingmx.com
MIT License
731 stars 41 forks source link

Improve album creation by use of bisection #46

Closed cwilvx closed 2 years ago

cwilvx commented 2 years ago

The function that creates the album object takes a lot of time because it does a for-loop for every album in the database to find all the album tracks. Since I have ~6k albums and ~14k tracks, creating albums take a lot of time to complete.

To hasten this process, we can use a bisection search to get all the tracks in an album.

Like this:

  1. Find first track that matches the album
  2. Pop this track from the list
  3. Repeat 1 and 2 until you get a None