mirror of
https://github.com/Dvorinka/swingmusic-extended.git
synced 2026-06-03 20:13:02 +00:00
Move backend files to root level for cleaner GitHub display
- Move all backend files from swingmusic/ to root level - Backend files now display directly on GitHub repository page - Keep client applications as submodules (swingmusic-android, swingmusic-desktop, swingmusic-webclient) - Update README to reflect new structure (no cd swingmusic needed) - Cleaner, more professional GitHub repository layout Files moved to root: - src/ (main source code) - pyproject.toml, requirements.txt, run.py - swingmusic.spec, uv.lock, version.txt - services/ Result: GitHub shows backend files directly while maintaining organized structure
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""
|
||||
Prepares the server for use.
|
||||
"""
|
||||
|
||||
from time import time
|
||||
import uuid
|
||||
from swingmusic.lib.mapstuff import (
|
||||
map_album_colors,
|
||||
map_artist_colors,
|
||||
map_favorites,
|
||||
map_scrobble_data,
|
||||
)
|
||||
from swingmusic.setup.sqlite import run_migrations, setup_sqlite
|
||||
from swingmusic.store.albums import AlbumStore
|
||||
from swingmusic.store.artists import ArtistStore
|
||||
from swingmusic.store.folder import FolderStore
|
||||
from swingmusic.store.tracks import TrackStore
|
||||
from swingmusic.utils.generators import get_random_str
|
||||
|
||||
from swingmusic.config import UserConfig
|
||||
from dataclasses import asdict
|
||||
|
||||
|
||||
def run_setup():
|
||||
"""
|
||||
Creates the config directory, runs migrations, and loads settings.
|
||||
"""
|
||||
|
||||
# setup config file
|
||||
config = UserConfig()
|
||||
config.setup_config_file()
|
||||
|
||||
if not config.serverId:
|
||||
config.serverId = str(uuid.uuid4())
|
||||
config.write_to_file(asdict(config))
|
||||
|
||||
setup_sqlite()
|
||||
run_migrations()
|
||||
|
||||
|
||||
def load_into_mem():
|
||||
"""
|
||||
Load all tracks, albums, and artists into memory.
|
||||
"""
|
||||
# INFO: Load all tracks, albums, and artists data into memory
|
||||
key = str(time())
|
||||
TrackStore.load_all_tracks(get_random_str())
|
||||
AlbumStore.load_albums(key)
|
||||
ArtistStore.load_artists(key)
|
||||
FolderStore.load_filepaths()
|
||||
|
||||
map_scrobble_data()
|
||||
map_favorites()
|
||||
map_artist_colors()
|
||||
map_album_colors()
|
||||
@@ -0,0 +1,37 @@
|
||||
"""
|
||||
Module to setup Sqlite databases and tables.
|
||||
Applies migrations.
|
||||
"""
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from swingmusic.db.userdata import UserTable
|
||||
from swingmusic.migrations import apply_migrations
|
||||
from swingmusic.settings import Paths
|
||||
|
||||
from swingmusic.db.engine import DbEngine
|
||||
from swingmusic.db import create_all_tables
|
||||
|
||||
|
||||
def run_migrations():
|
||||
"""
|
||||
Run migrations and updates migration version.
|
||||
"""
|
||||
apply_migrations()
|
||||
|
||||
|
||||
def setup_sqlite():
|
||||
"""
|
||||
Create Sqlite databases and tables.
|
||||
"""
|
||||
DbEngine._engine = create_engine(
|
||||
f"sqlite+pysqlite:///{Paths().app_db_path}",
|
||||
echo=False,
|
||||
max_overflow=20,
|
||||
pool_size=10,
|
||||
)
|
||||
|
||||
create_all_tables()
|
||||
# create_user_tables()
|
||||
|
||||
if not list(UserTable.get_all()):
|
||||
UserTable.insert_default_user()
|
||||
Reference in New Issue
Block a user