mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-23 19:21:12 +01:00
- New: Field inside format general tab to enable include format in rename - New: Database migration that adds format renames table - New: Queries to get / update rename status for a format - Update: Format compiler checks for rename entries and add include rename field when found - Update: Parsing improvements for incoming commit messages
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
# backend/app/db/queries/format_renames.py
|
|
import logging
|
|
from ..connection import get_db
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def add_format_to_renames(format_name: str) -> None:
|
|
"""Add a format to the renames table"""
|
|
with get_db() as conn:
|
|
conn.execute(
|
|
'INSERT OR REPLACE INTO format_renames (format_name) VALUES (?)',
|
|
(format_name, ))
|
|
conn.commit()
|
|
logger.info(f"Added format to renames table: {format_name}")
|
|
|
|
|
|
def remove_format_from_renames(format_name: str) -> None:
|
|
"""Remove a format from the renames table"""
|
|
with get_db() as conn:
|
|
conn.execute('DELETE FROM format_renames WHERE format_name = ?',
|
|
(format_name, ))
|
|
conn.commit()
|
|
logger.info(f"Removed format from renames table: {format_name}")
|
|
|
|
|
|
def is_format_in_renames(format_name: str) -> bool:
|
|
"""Check if a format is in the renames table"""
|
|
with get_db() as conn:
|
|
result = conn.execute(
|
|
'SELECT 1 FROM format_renames WHERE format_name = ?',
|
|
(format_name, )).fetchone()
|
|
return bool(result)
|