(group_id: int, project_id: int | None = None)
| 716 | |
| 717 | |
| 718 | def 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 |
no test coverage detected