mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-04 20:43:04 +00:00
combine userdata and swing db into one
+ port populate to new db interface
+ add genrehashes and hash info to tracks
+ properly structure new db table files
+ move helpers to dedicated utils file
+ move settings from db to config file
+ move artists, albums, auth and favorites endpoint to new db interface
+ use folder store to index filepaths
+ paginate favorite pages
+ 56 moretiny changes 😅
This commit is contained in:
+11
-10
@@ -3,11 +3,11 @@ Prepares the server for use.
|
||||
"""
|
||||
|
||||
import uuid
|
||||
from app.db.sqlite.settings import load_settings
|
||||
from app.setup.files import create_config_dir
|
||||
from app.setup.sqlite import run_migrations, setup_sqlite
|
||||
from app.store.albums import AlbumStore
|
||||
from app.store.artists import ArtistStore
|
||||
from app.store.folder import FolderStore
|
||||
from app.store.tracks import TrackStore
|
||||
from app.utils.generators import get_random_str
|
||||
from app.config import UserConfig
|
||||
@@ -29,20 +29,21 @@ def run_setup():
|
||||
setup_sqlite()
|
||||
run_migrations()
|
||||
|
||||
try:
|
||||
load_settings()
|
||||
except IndexError:
|
||||
# settings table is empty
|
||||
pass
|
||||
# try:
|
||||
# load_settings()
|
||||
# except IndexError:
|
||||
# # settings table is empty
|
||||
# pass
|
||||
|
||||
|
||||
def load_into_mem():
|
||||
"""
|
||||
Load all tracks, albums, and artists into memory.
|
||||
"""
|
||||
instance_key = get_random_str()
|
||||
# instance_key = get_random_str()
|
||||
|
||||
# INFO: Load all tracks, albums, and artists into memory
|
||||
TrackStore.load_all_tracks(instance_key)
|
||||
AlbumStore.load_albums(instance_key)
|
||||
ArtistStore.load_artists(instance_key)
|
||||
# TrackStore.load_all_tracks(instance_key)
|
||||
# AlbumStore.load_albums(instance_key)
|
||||
# ArtistStore.load_artists(instance_key)
|
||||
FolderStore.load_filepaths()
|
||||
+8
-14
@@ -3,11 +3,15 @@ Module to setup Sqlite databases and tables.
|
||||
Applies migrations.
|
||||
"""
|
||||
|
||||
from app.db.userdata import UserTable
|
||||
from app.db.sqlite import create_connection, create_tables, queries
|
||||
from app.db.sqlite.auth import SQLiteAuthMethods as authdb
|
||||
from app.migrations import apply_migrations
|
||||
from app.settings import Db
|
||||
|
||||
from app.db import create_all
|
||||
from app.db.libdata import create_all as create_all_libdata
|
||||
|
||||
|
||||
def run_migrations():
|
||||
"""
|
||||
@@ -20,18 +24,8 @@ def setup_sqlite():
|
||||
"""
|
||||
Create Sqlite databases and tables.
|
||||
"""
|
||||
# if os.path.exists(DB_PATH):
|
||||
# os.remove(DB_PATH)
|
||||
create_all()
|
||||
create_all_libdata()
|
||||
|
||||
app_db_conn = create_connection(Db.get_app_db_path())
|
||||
user_db_conn = create_connection(Db.get_userdata_db_path())
|
||||
|
||||
create_tables(app_db_conn, queries.CREATE_APPDB_TABLES)
|
||||
create_tables(user_db_conn, queries.CREATE_USERDATA_TABLES)
|
||||
create_tables(app_db_conn, queries.CREATE_MIGRATIONS_TABLE)
|
||||
|
||||
if not authdb.get_all_users():
|
||||
authdb.insert_default_user()
|
||||
|
||||
app_db_conn.close()
|
||||
user_db_conn.close()
|
||||
if not UserTable.get_all():
|
||||
UserTable.insert_default_user()
|
||||
|
||||
Reference in New Issue
Block a user