diff --git a/backend/src/events/process.py b/backend/src/events/process.py index 3c957b03..227b4743 100644 --- a/backend/src/events/process.py +++ b/backend/src/events/process.py @@ -37,6 +37,20 @@ def add_event_to_db(event: EventLLM) -> bool: categories = get_categories() with Session(engine) as session: + # Check for duplicates + eventORM = session.scalars( + select(Event).where( + Event.title == event.title, + Event.description == Event.description, + Event.duplicate == event.duplicate, + Event.is_singapore == event.is_singapore, + Event.original_article_id == event.original_article_id, + ) + ).first() + if eventORM: + print("duplicate detected:", event) + return False + try: article = session.get(Article, event.original_article_id) if not article: diff --git a/backend/src/scripts/seed.py b/backend/src/scripts/seed.py index ee76df83..387b6da2 100644 --- a/backend/src/scripts/seed.py +++ b/backend/src/scripts/seed.py @@ -97,4 +97,4 @@ def test_associations(): # session.delete(original_article) -# test_associations() +test_associations()