Skip to content

Improve Django Admin contract list usability#446

Open
kingksjo wants to merge 1 commit intoSoroScan:mainfrom
kingksjo:feat/django-admin-contract-list
Open

Improve Django Admin contract list usability#446
kingksjo wants to merge 1 commit intoSoroScan:mainfrom
kingksjo:feat/django-admin-contract-list

Conversation

@kingksjo
Copy link
Copy Markdown
Contributor

Improve Django Admin Contract List Usability

Description

This PR improves the usability and performance of the Django Admin contract list view. While the search, filter, and ordering configurations were already present, this PR adds the necessary database indexes to ensure these operations remain performant as the number of contracts grows (100+).

Key Changes

  • Database Indexes: Added db_index=True to TrackedContract.name and TrackedContract.created_at.
    • Sort by name now uses an index scan.
    • Sort by created_at (the default admin ordering) now uses an index scan.
  • Migration: Added migration 0039 to apply these index changes.

Related Issues

Closes #316

Verification Steps

  1. System Check:
    python manage.py check --settings=soroscan.settings_test
  2. Migration Check:
    python manage.py makemigrations --check --settings=soroscan.settings_test
  3. Run Admin Tests:
    pytest soroscan/ingest/tests/test_admin_contract_list.py -v
  4. Run Regression Tests:
    pytest soroscan/ingest/tests/test_admin_actions.py -v

Test Results

  • Admin Contract List Tests: 27/27 PASSED
  • Admin Actions Tests: 3/3 PASSED

Visual Verification (Manual)

  • Search by contract address and name works as expected.
  • Filters for is_active and network are present and functional in the sidebar.
  • Sorting by created_at and name is active and performant.

- Adds db_index=True to TrackedContract.name for efficient ORDER BY name
  in the admin list (was hitting a seq scan at 100+ contracts)
- Adds db_index=True to TrackedContract.created_at for efficient ORDER BY
  -created_at, the default admin ordering on every page load
- Adds migration 0039 (reversible AlterField operations, no data loss)

Admin search, filters, and ordering were already implemented and passing
all 27 tests in test_admin_contract_list.py — this PR completes the work
by closing the remaining DB performance gap for sort operations.

Closes SoroScan#277
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Apr 28, 2026

@kingksjo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

Enhance Django Admin with search and filtering on contract list

1 participant