MCPcopy
hub / github.com/getsentry/sentry / get_progress

Function get_progress

src/sentry/reprocessing2.py:718–743  ·  view source on GitHub ↗
(group_id: int, project_id: int | None = None)

Source from the content-addressed store, hash-verified

716
717
718def get_progress(group_id: int, project_id: int | None = None) -> tuple[int, Any | None]:
719 pending, ttl = reprocessing_store.get_pending(group_id)
720 info = reprocessing_store.get_progress(group_id)
721 if pending is None:
722 logger.error("reprocessing2.missing_counter")
723 return 0, None
724 if info is None:
725 logger.error("reprocessing2.missing_info")
726 return 0, None
727
728 # We expect reprocessing to make progress every now and then, by bumping the
729 # TTL of the "counter" key. If that TTL wasn't bumped in a while, we just
730 # assume that reprocessing is stuck, and will just call finish on it.
731 if project_id is not None and ttl is not None and ttl > 0:
732 default_ttl = settings.SENTRY_REPROCESSING_SYNC_TTL
733 age = default_ttl - ttl
734 if age > REPROCESSING_TIMEOUT:
735 from sentry.tasks.reprocessing2 import finish_reprocessing
736
737 finish_reprocessing.delay(project_id=project_id, group_id=group_id)
738
739 # Our internal sync counters are counting over *all* events, but the
740 # progressbar in the frontend goes until max_events. Advance progressbar
741 # proportionally.
742 _pending = int(int(pending) * info["totalEvents"] / float(info.get("syncCount") or 1))
743 return _pending, info

Callers 2

_get_statusMethod · 0.90
is_group_finishedFunction · 0.85

Calls 5

delayMethod · 0.80
getMethod · 0.65
get_pendingMethod · 0.45
get_progressMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected