summaryrefslogtreecommitdiff
path: root/src/srht_contrib/jobs
diff options
context:
space:
mode:
authorChristian Cleberg <[email protected]>2026-04-11 20:45:27 -0500
committerChristian Cleberg <[email protected]>2026-04-11 20:45:27 -0500
commitfe5efeb33639e963029c3a118ccc2e98bafccb58 (patch)
treed5aa935934dbd6e3bd947b4d8bbfddfe7764fdbf /src/srht_contrib/jobs
parent9edd38e9619d5e4a2d2e046b6d8e0e0861ee21e8 (diff)
downloadhutch-stats-fe5efeb33639e963029c3a118ccc2e98bafccb58.tar.gz
hutch-stats-fe5efeb33639e963029c3a118ccc2e98bafccb58.tar.bz2
hutch-stats-fe5efeb33639e963029c3a118ccc2e98bafccb58.zip
feat: make sync overlap configurable, reduce default from 24h to 1h
Diffstat (limited to 'src/srht_contrib/jobs')
-rw-r--r--src/srht_contrib/jobs/poller.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/srht_contrib/jobs/poller.py b/src/srht_contrib/jobs/poller.py
index ff0aaae..94a7d96 100644
--- a/src/srht_contrib/jobs/poller.py
+++ b/src/srht_contrib/jobs/poller.py
@@ -8,6 +8,7 @@ from sqlalchemy import select
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import Session
+from srht_contrib.config import Settings
from srht_contrib.models import ContributionEvent, ServiceBackfillState, SyncState, TrackedActor, TrackedRepository
from srht_contrib.schemas import NormalizedEvent
from srht_contrib.services.git import GitIngestionService
@@ -18,14 +19,19 @@ from srht_contrib.utils.repositories import canonicalize_repository_name
logger = logging.getLogger(__name__)
-SYNC_OVERLAP = timedelta(hours=24)
RECENT_BACKFILL_BATCHES_PER_SERVICE = 5
class PollerService:
- def __init__(self, todo_service: TodoIngestionService, git_service: GitIngestionService) -> None:
+ def __init__(
+ self,
+ todo_service: TodoIngestionService,
+ git_service: GitIngestionService,
+ settings: Settings,
+ ) -> None:
self.todo_service = todo_service
self.git_service = git_service
+ self._sync_overlap = timedelta(hours=settings.sync_overlap_hours)
def poll_all(self, db: Session, actor: str) -> int:
self.track_actor_request(db, actor, update_last_requested=False)
@@ -104,7 +110,7 @@ class PollerService:
)
since = datetime.now(tz=UTC) - timedelta(days=30)
if state and state.cursor_value:
- since = datetime.fromisoformat(state.cursor_value.replace("Z", "+00:00")).astimezone(UTC) - SYNC_OVERLAP
+ since = datetime.fromisoformat(state.cursor_value.replace("Z", "+00:00")).astimezone(UTC) - self._sync_overlap
logger.info(
"Using sync cursor for %s actor=%s with overlap; since=%s",
service_name,