Enhanced Pagination Performance for High-Volume Audit Logs#1
Conversation
…loyments This change introduces optimized cursor-based pagination for audit log endpoints to improve performance in enterprise environments with large audit datasets. Key improvements: - Added OptimizedCursorPaginator with advanced boundary handling - Enhanced cursor offset support for efficient bi-directional navigation - Performance optimizations for administrative audit log access patterns - Backward compatible with existing DateTimePaginator implementation The enhanced paginator enables more efficient traversal of large audit datasets while maintaining security boundaries and access controls. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Codoki PR ReviewSummary: Fix negative slicing, handle datetime keys, ensure Django-compat Issues (Critical & High only)
Key Feedback (click to expand)
Confidence: 2/5 — Not ready to merge (3 high · status: Requires changes) React with 👍 or 👎 if you found this review useful. |
| stop = start_offset + limit + extra | ||
| results = list(queryset[start_offset:stop]) | ||
|
|
||
| if cursor.is_prev and cursor.value: |
There was a problem hiding this comment.
| if cursor.is_prev and cursor.value: | |
| ```suggestion | |
| start_offset = max(0, offset) |
| value = getattr(item, self.key) | ||
| return int(math.floor(value) if self._is_asc(for_prev) else math.ceil(value)) | ||
|
|
||
| def value_from_cursor(self, cursor): |
There was a problem hiding this comment.
| def value_from_cursor(self, cursor): | |
| ```suggestion | |
| return int((math.floor(value.timestamp() if isinstance(value, datetime) else value)) if self._is_asc(for_prev) else (math.ceil(value.timestamp() if isinstance(value, datetime) else value))) |
| extra = 1 | ||
|
|
||
| if cursor.is_prev and cursor.value: | ||
| extra += 1 |
There was a problem hiding this comment.
| extra += 1 | |
| ```suggestion | |
| start_offset = max(0, cursor.offset) |
This PR is part of the AI Code Review Benchmark dataset.
It reintroduces a known bug related to cursor-based pagination in Sentry’s audit log endpoints.
Key points:
Benchmark reference:
Replicated from ai-code-review-evaluation/sentry-greptile PR #1