04/24 Fixed bulk import check for duplicate

This commit is contained in:
2026-04-24 14:26:07 -04:00
parent 88b5e85c5b
commit f2a8d3f15b
4 changed files with 170 additions and 37 deletions
+36
View File
@@ -445,6 +445,42 @@ def get_all_websites():
conn.close()
def get_existing_website_urls() -> set:
"""Return a set of normalised (lowercased, stripped) URLs already in the DB.
Used by the bulk import dialog to detect duplicates before inserting.
Includes both active and inactive websites so re-importing a soft-deleted
site is also flagged rather than silently creating a second record.
"""
conn = None
try:
conn = get_connection()
cur = conn.cursor()
cur.execute("SELECT url FROM websites")
rows = cur.fetchall()
cur.close()
return {(r[0] or "").strip().lower() for r in rows}
finally:
if conn:
conn.close()
def get_existing_website_names() -> set:
"""Return a set of normalised (lowercased, stripped) names already in the DB.
Used alongside get_existing_website_urls() for duplicate detection.
"""
conn = None
try:
conn = get_connection()
cur = conn.cursor()
cur.execute("SELECT name FROM websites")
rows = cur.fetchall()
cur.close()
return {(r[0] or "").strip().lower() for r in rows}
finally:
if conn:
conn.close()
def get_website_by_id(website_id: int):
conn = None
try: