rewrite remove duplicates to support removing duplicates in albums tracks efficiently

+ remove flags added to client settings page
+ misc
This commit is contained in:
mungai-njoroge
2023-08-29 20:04:30 +03:00
parent 26e36ba36f
commit 13475b0630
16 changed files with 118 additions and 95 deletions
+2 -6
View File
@@ -3,8 +3,6 @@ Contains all the album routes.
"""
import random
from dataclasses import asdict
from typing import Any
from flask import Blueprint, request
@@ -18,7 +16,6 @@ from app.serializers.track import serialize_track
from app.store.albums import AlbumStore
from app.store.tracks import TrackStore
from app.utils.hashing import create_hash
from app.utils.remove_duplicates import remove_duplicates
get_albums_by_albumartist = adb.get_albums_by_albumartist
check_is_fav = favdb.check_is_favorite
@@ -67,13 +64,12 @@ def get_album_tracks_and_info():
return list(genres)
album.genres = get_album_genres(tracks)
tracks = remove_duplicates(tracks)
album.count = len(tracks)
album.get_date_from_tracks(tracks)
try:
album.duration = sum((t.duration for t in tracks))
album.duration = sum(t.duration for t in tracks)
except AttributeError:
album.duration = 0
+7 -7
View File
@@ -4,7 +4,7 @@ from app.db.sqlite.settings import SettingsSQLMethods as sdb
from app.lib import populate
from app.lib.watchdogg import Watcher as WatchDog
from app.logger import log
from app.settings import ParserFlags, Paths, set_flag
from app.settings import Paths, SessionVarKeys, set_flag
from app.store.albums import AlbumStore
from app.store.artists import ArtistStore
from app.store.tracks import TrackStore
@@ -143,12 +143,12 @@ def get_root_dirs():
# maps settings to their parser flags
mapp = {
"artist_separators": ParserFlags.ARTIST_SEPARATORS,
"extract_feat": ParserFlags.EXTRACT_FEAT,
"remove_prod": ParserFlags.REMOVE_PROD,
"clean_album_title": ParserFlags.CLEAN_ALBUM_TITLE,
"remove_remaster": ParserFlags.REMOVE_REMASTER_FROM_TRACK,
"merge_albums": ParserFlags.MERGE_ALBUM_VERSIONS,
"artist_separators": SessionVarKeys.ARTIST_SEPARATORS,
"extract_feat": SessionVarKeys.EXTRACT_FEAT,
"remove_prod": SessionVarKeys.REMOVE_PROD,
"clean_album_title": SessionVarKeys.CLEAN_ALBUM_TITLE,
"remove_remaster": SessionVarKeys.REMOVE_REMASTER_FROM_TRACK,
"merge_albums": SessionVarKeys.MERGE_ALBUM_VERSIONS,
}