# helpers/db_moments.py
from typing import List, Dict
from config import get_local_db_connection

def add_moment(video_uuid: str, ts_seconds: int) -> str:
    conn, cursor = get_local_db_connection()
    cursor.execute(
        "INSERT INTO moments (video_id, timestamp) VALUES (%s, %s)",
        (video_uuid, ts_seconds),
    )
    conn.commit()
    new_id = cursor.lastrowid
    cursor.close(); conn.close()
    return new_id

def list_moments(video_uuid: str):
    conn, cursor = get_local_db_connection()
    cursor.execute(
        "SELECT id, timestamp FROM moments WHERE video_id = %s ORDER BY timestamp ASC",
        (video_uuid,),
    )
    rows = cursor.fetchall()
    cursor.close(); conn.close()
    return rows
