mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
add a store method to count the number of tracks in a folder
~ Courtesy of chatgpt3.5 + add a few a TODO
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
from pprint import pprint
|
||||
|
||||
from app.db.store import Store
|
||||
from app.models import Folder, Track
|
||||
@@ -50,10 +51,16 @@ class GetFilesAndDirs:
|
||||
|
||||
tracks = Store.get_tracks_by_filepaths(files)
|
||||
|
||||
# TODO: Remove this threadpool and modify the get_folder store
|
||||
# method to accept a list of paths.
|
||||
with ThreadPoolExecutor() as pool:
|
||||
iterable = pool.map(Store.get_folder, dirs)
|
||||
folders = [i for i in iterable if i is not None]
|
||||
|
||||
folders = filter(lambda f: f.has_tracks, folders)
|
||||
|
||||
folders_with_count_dict = Store.get_folders_count(dirs)
|
||||
pprint(folders_with_count_dict)
|
||||
# TODO: Map folder count to folder object
|
||||
|
||||
return tracks, folders # type: ignore
|
||||
|
||||
Reference in New Issue
Block a user