Skip to content

Commit

Permalink
chore: enable cron again
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpomerenke committed Aug 7, 2024
1 parent 1213478 commit 7d8b6b0
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions backend-python/media_impact_monitor/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def fill_cache():
print("Filling cache...")
errors = []
events = {}
for data_source in ["acled", "press_releases"]:
for data_source in ["acled"]: # , "press_releases"]:
print(f"Retrieving {data_source} events...")
try:
events[data_source] = get_events(
Expand Down Expand Up @@ -75,20 +75,23 @@ def fill_cache():
)
events = events["acled"] # TODO: include press_releases
recent_events = events[events["date"] >= date.today() - timedelta(days=70)]
# for event in tqdm(
# list(recent_events.itertuples()),
# desc="Retrieving event fulltexts",
# ):
# try:
# get_fulltexts(
# FulltextSearch(
# media_source="news_online",
# event_id=event.event_id,
# )
# )
# except Exception as e:
# errors.append(f"fulltexts {event.event_id}: {e}")
for event in tqdm(
list(recent_events.itertuples()),
desc="Retrieving event fulltexts",
):
try:
get_fulltexts(
FulltextSearch(
media_source="news_online",
event_id=event.event_id,
)
)
except Exception as e:
errors.append(f"fulltexts {event.event_id}: {e}")
if errors:
raise ValueError(f"Errors occurred: {'; '.join(errors)}")
print("Successfully filled cache!")
return


fill_cache()

0 comments on commit 7d8b6b0

Please sign in to comment.