"""
mark_tatinek_zbytek.py — Zbytek Tatinek U (produktové letáky, Sudoku,
screenshoty, web obrázky) -> odpad. Potvrzeno uživatelem.
Vše krom Fractal/DarthAnihilator/Screenshots/Compass -> Odpad-cache.
"""
import sys
import psycopg2

sys.stdout.reconfigure(encoding="utf-8")

DB = dict(host="192.168.1.76", port=5432, user="vladimir.buzalka",
          password="Vlado7309208104++", database="fotky_buzalkovi")

conn = psycopg2.connect(**DB)
conn.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
cur = conn.cursor()

cur.execute("""
    UPDATE photos p
    SET wanted = FALSE, category = 'Odpad-cache'
    FROM zaloha_obrazku z
    WHERE p.zaloha_id = z.id
      AND z.cesta_zalohy LIKE '/mnt/user/ZalohaVsechObrazku/Tower1/#ColdData/Tatinek U/%'
      AND z.cesta_zalohy NOT LIKE '%Fractal%'
      AND z.cesta_zalohy NOT LIKE '%/DarthAnihilator/%'
      AND z.cesta_zalohy NOT LIKE '%/Screenshots/%'
      AND z.cesta_zalohy NOT LIKE '%/Duplicates/Compass/%'
      AND p.category IS DISTINCT FROM 'Odpad-cache'
""")

print(f"Tatinek U (zbytek) -> Odpad-cache: {cur.rowcount:,} řádků")
conn.close()
