"""
mark_pomoc.py — Tower1/#ColdData/pomoc, potvrzeno uživatelem:
  Samsung GT-S5230 (s EXIF) -> Rodina
  porno snapshoty (bez EXIF) -> Porno
"""
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")

P = "/mnt/user/ZalohaVsechObrazku/Tower1/#ColdData/pomoc/%"

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

# Samsung (s EXIF) -> Rodina
cur.execute("""
    UPDATE photos p SET wanted=TRUE, category='Rodina'
    FROM zaloha_obrazku z
    WHERE p.zaloha_id=z.id AND z.cesta_zalohy LIKE %s
      AND p.camera_make IS NOT NULL
      AND (p.wanted=FALSE OR p.category IS DISTINCT FROM 'Rodina')
""", (P,))
print(f"  pomoc Samsung -> Rodina: {cur.rowcount:,}")

# porno (bez EXIF) -> Porno
cur.execute("""
    UPDATE photos p SET wanted=FALSE, category='Porno'
    FROM zaloha_obrazku z
    WHERE p.zaloha_id=z.id AND z.cesta_zalohy LIKE %s
      AND p.camera_make IS NULL
      AND p.category IS DISTINCT FROM 'Porno'
""", (P,))
print(f"  pomoc porno   -> Porno : {cur.rowcount:,}")

conn.close()
print("Hotovo.")
