Admin console improvements + fixes - #326
Conversation
Co-authored-by: Lucas Parzianello <lucaspar@users.noreply.github.com>
Changed Files
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e941838. Configure here.
| }, | ||
| }, | ||
| "root": {"level": "DEBUG", "handlers": ["console"]}, | ||
| "root": {"level": "DEBUG", "handlers": ["console", "file"]}, |
There was a problem hiding this comment.
Shared log file rotation
High Severity
The RotatingFileHandler writes to a shared gateway.log file from multiple application processes. This handler isn't process-safe, which can lead to interleaved, lost, or corrupted log lines and unreliable rotation.
Reviewed by Cursor Bugbot for commit e941838. Configure here.
| @admin.display(description="# Cap", ordering="_capture_count") | ||
| def capture_count(self, obj): | ||
| count = getattr(obj, "_capture_count", 0) | ||
| return count or "-" |
There was a problem hiding this comment.
Zero counts show as dash
Low Severity
New admin list columns use count or "-" (or treat zero as falsy before formatting), so a legitimate count of zero renders as - instead of 0 or 0 files, making rows with no related captures, datasets, or files look like missing data rather than an empty relation.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e941838. Configure here.
| .get_queryset(request) | ||
| .select_related("owner") | ||
| .annotate(_dataset_count=Count("datasets"), _file_count=Count("files")) | ||
| ) |
There was a problem hiding this comment.
Dual M2M counts inflate admin
Medium Severity
CaptureAdmin and DatasetAdmin now annotate each row with two Count() values over different many-to-many relations in one queryset. Django’s ORM can multiply join rows in that pattern, so changelist “Files”, “# Ds”, and related columns can show numbers far above the true relation counts when both sides have multiple links.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e941838. Configure here.


Original PR: #324
Summary
Verification
python3 -m py_compile sds_gateway/api_methods/tests/test_federation_signals.py sds_gateway/api_methods/tests/test_federation_sync_api_key.pyjust, Docker, and a project virtualenv.Note
Medium Risk
The admin index runs several aggregate queries on every load (mitigated by tests for query bounds and fallbacks), and production logging touches shared volumes across app/Celery containers; federation API-key test changes document security-sensitive mint behavior.
Overview
This PR replaces the default Django admin index with a Gateway Dashboard that aggregates file/capture/dataset/user stats, cleanup candidates, system health, and admin user tables, backed by new
sds_gateway/admin.py, template/CSS, and tests (including DB-failure fallbacks).Production logging adds a shared
sds-gateway-prod-app-logsvolume mounted at/app/logson app and Celery services, creates the log directory at startup, and writes/app/logs/gateway.logvia a rotating file handler alongside console output.Admin changelists are expanded across api_methods, users, and visualizations (counts, formatted sizes,
select_related/annotations).static_cache_bustingnow cachesversion.jsononce at import instead of per request.Federation tests add missing
_mock_publishparameters on patched signal tests and align the sync API-key HTTP test with minting a key for the authenticated federation-sync service user (not theemailquery target). Gateway and SDK pytest configs gain--durations=10; gateway/sdk justfiles standardizeCOLUMNS=119.Reviewed by Cursor Bugbot for commit e941838. Bugbot is set up for automated code reviews on this repo. Configure here.