"""
mark_dedup_rodina.py — DedupPhotos (Samsung S7 Edge 2019, 285 ks).
Ověřeno: všechny unikátní, žádné duplikáty jinde -> Rodina.
"""
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 = TRUE, category = 'Rodina'
    FROM zaloha_obrazku z
    WHERE p.zaloha_id = z.id
      AND z.cesta_zalohy LIKE %s
      AND (p.wanted = FALSE OR p.category IS DISTINCT FROM 'Rodina')
""", ('/mnt/user/ZalohaVsechObrazku/Tower1/#ColdData/DedupPhotos/%',))

print(f"DedupPhotos -> Rodina: {cur.rowcount:,} řádků")
conn.close()
