Save complete tracks and albums to the db for faster startup

- refactor function locations
- add logger
- check for new tracks instead of re-processing all files
This commit is contained in:
geoffrey45
2022-04-21 10:16:45 +03:00
parent ef68cae625
commit d98cc0547e
22 changed files with 448 additions and 380 deletions
+4 -2
View File
@@ -5,6 +5,8 @@ album documents in MongoDB.
from app import db
from bson import ObjectId
from app.models import Album
convert_many = db.convert_many
convert_one = db.convert_one
@@ -18,13 +20,13 @@ class Albums(db.Mongo):
super(Albums, self).__init__("ALICE_ALBUMS")
self.collection = self.db["ALL_ALBUMS"]
def insert_album(self, album: dict) -> None:
def insert_album(self, album: Album) -> None:
"""
Inserts a new album object into the database.
"""
return self.collection.update_one(
{
"album": album["album"],
"album": album["title"],
"artist": album["artist"]
},
{
+1 -1
View File
@@ -31,7 +31,7 @@ class AllSongs(db.Mongo):
},
upsert=True).upserted_id
def get_all_songs(self) -> list:
def get_all_tracks(self) -> list:
"""
Returns all tracks in the database.
"""