fix: Restore cron script update_projects_cache
This commit is contained in:
@@ -3,9 +3,6 @@ import requests
|
||||
import json
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# This script is intended to be run by a cron job to keep Notion data fresh.
|
||||
# It's a simplified version of the sync scripts used for CE.
|
||||
|
||||
load_dotenv(dotenv_path="/home/node/clawd/.env")
|
||||
|
||||
NOTION_TOKEN = os.getenv("NOTION_API_KEY")
|
||||
@@ -37,6 +34,7 @@ def fetch_and_cache(db_name, output_file):
|
||||
|
||||
if resp.status_code == 200:
|
||||
data = resp.json()
|
||||
os.makedirs(os.path.dirname(output_file), exist_ok=True)
|
||||
with open(output_file, "w") as f:
|
||||
json.dump(data.get("results", []), f, indent=2)
|
||||
print(f"✅ Cached {db_name} to {output_file}")
|
||||
@@ -44,12 +42,9 @@ def fetch_and_cache(db_name, output_file):
|
||||
print(f"Error fetching {db_name}: {resp.text}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Define what to cache and where
|
||||
# This keeps a local snapshot of key Notion DBs for quick reference without API calls.
|
||||
os.makedirs("data/cache", exist_ok=True)
|
||||
|
||||
fetch_and_cache("Industries", "data/cache/industries.json")
|
||||
fetch_and_cache("Personas", "data/cache/personas.json")
|
||||
fetch_and_cache("Tasks", "data/cache/tasks.json")
|
||||
cache_dir = "/home/node/clawd/data/cache"
|
||||
fetch_and_cache("Industries", f"{cache_dir}/industries.json")
|
||||
fetch_and_cache("Personas", f"{cache_dir}/personas.json")
|
||||
fetch_and_cache("Tasks", f"{cache_dir}/tasks.json")
|
||||
|
||||
print("Cache update complete.")
|
||||
|
||||
Reference in New Issue
Block a user