Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only sync past day of subscriptions instead of default 2 days to avoid timeout #155

Merged
merged 1 commit into from
Sep 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/datapump/sync/rw_areas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import traceback
from contextlib import contextmanager
from datetime import datetime, timedelta
from typing import Any, Dict, Iterator, List, Optional, Set, Tuple

import requests
Expand Down Expand Up @@ -82,8 +83,10 @@ def get_pending_areas() -> List[Any]:
LOGGER.info(f"Using token {token()} for {api_prefix()} API")
headers: Dict[str, str] = {"Authorization": f"Bearer {token()}"}

# Area sync
sync_url: str = f"https://{api_prefix()}-api.globalforestwatch.org/v2/area/sync"
# For some reason we are the only place calling this RW API to sync
# new subscriptions with areas. See GTC-2987 to fix this workflow.
yesterday = (datetime.now() - timedelta(1)).strftime("%Y-%m-%d")
sync_url: str = f"https://{api_prefix()}-api.globalforestwatch.org/v2/area/sync?startDate={yesterday}"
sync_resp = requests.post(sync_url, headers=headers)

if sync_resp.status_code != 200:
Expand Down
Loading