Skip to content

Admin console improvements + fixes - #326

Merged
lucaspar merged 10 commits into
masterfrom
cursor/continuous-integration-failures-56c0
Jul 27, 2026
Merged

Admin console improvements + fixes#326
lucaspar merged 10 commits into
masterfrom
cursor/continuous-integration-failures-56c0

Conversation

@cursor

@cursor cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

Original PR: #324

  • Admin console
    • Added a service health overview to the home console, if possible
    • Fixed 500 errors when searching things
    • More useful columns in admin console tables
    • Health dashboard and system overview as admin home
    • Safeguards to prevent operators from being locked out in case the dashboard fails to render
  • Observability
    • Production config preserves logs in a Docker volume

Summary

  • Add missing patched mock parameters in federation signal tests.
  • Update the federation sync API-key endpoint test to expect a key for the authenticated federation-sync service user.

Verification

  • python3 -m py_compile sds_gateway/api_methods/tests/test_federation_signals.py sds_gateway/api_methods/tests/test_federation_sync_api_key.py
  • CI-equivalent focused Django tests could not be run locally because this cloud image lacks just, Docker, and a project virtualenv.
Open in Web View Automation 

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-logs volume mounted at /app/logs on app and Celery services, creates the log directory at startup, and writes /app/logs/gateway.log via 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_busting now caches version.json once at import instead of per request.

Federation tests add missing _mock_publish parameters on patched signal tests and align the sync API-key HTTP test with minting a key for the authenticated federation-sync service user (not the email query target). Gateway and SDK pytest configs gain --durations=10; gateway/sdk justfiles standardize COLUMNS=119.

Reviewed by Cursor Bugbot for commit e941838. Bugbot is set up for automated code reviews on this repo. Configure here.

@semanticdiff-com

semanticdiff-com Bot commented Jul 27, 2026

Copy link
Copy Markdown

@lucaspar
lucaspar marked this pull request as ready for review July 27, 2026 16:38
@lucaspar
lucaspar merged commit e159931 into master Jul 27, 2026
2 of 3 checks passed
@lucaspar
lucaspar deleted the cursor/continuous-integration-failures-56c0 branch July 27, 2026 16:38

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

Fix All in Cursor

❌ 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"]},

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

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 "-"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e941838. Configure here.

.get_queryset(request)
.select_related("owner")
.annotate(_dataset_count=Count("datasets"), _file_count=Count("files"))
)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit e941838. Configure here.

@lucaspar lucaspar changed the title Fix federation CI test expectations Admin console improvements + fixes Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants