Skip to content

Commit

Permalink
log if new data was found when querying notion
Browse files Browse the repository at this point in the history
  • Loading branch information
Highfire1 committed Apr 19, 2024
1 parent 6f9bdcc commit 08c6e63
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions notion.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,33 @@ def multiplePropTextExtractor(property:dict) -> list[str] | None:
# extract only the information that we need:
executives: list[LCSCExecutive] = []
executive_images: dict[str, str] = {}

all_stale = True
# check to see if all data is stale : if it is then we can exit early.
for page in exec_pages["results"]:
assert page["object"] == "page"

p = page["properties"]

last_updated = page["last_edited_time"]
student_id = propTextExtractor(p["Student ID"]),

# don't go through the trouble of everything if the page hasn't changed
# right now everything is simply downloading the exec images
for exec in cached_data:
if exec["student_id"] == student_id[0]:
if last_updated != exec["last_updated"]:
all_stale = False
break

if not all_stale:
break

if all_stale:
print("No new data found from Notion.")
return
else:
print("New data found in Notion: recreating cache:")

for page in exec_pages["results"]:

Expand Down

0 comments on commit 08c6e63

Please sign in to comment.