Skip to content

Django admin action: run/refresh Wikidata property sync on demand #34

@gregoryfoster

Description

@gregoryfoster

Background

sync_wikidata_properties is currently only runnable via the management command CLI. Operators need a way to trigger a refresh from the Django admin without SSH access — for example, after Wikidata adds new identifier properties relevant to persons, or to re-sync after enabling new ExternalPlatform entries.

Related to #33 (auto-sync on first run).

Proposed feature

Add a custom Django admin action (or admin view) on ExternalIdentifierPropertyAdmin that:

  1. Runs sync_wikidata_properties logic inline (extracted to a callable in models.py or a service module so both the management command and admin action can call it).
  2. Displays a confirmation page before executing (since the operation takes ~5–10 min and makes external SPARQL calls).
  3. Reports results: rows created, rows updated, rows unchanged, duration.
  4. Locks out concurrent runs (atomic flag or DB row lock) to prevent double-execution.

Design note

The sync command logic should be extracted from the management command into a sync_wikidata_properties() service function in src/core/ or src/web/persons/services.py — keeping the management command as a thin wrapper. This makes it callable from the admin action, tests, and future cron tasks (#28) without duplicating SPARQL logic.

Acceptance criteria

  • Service function extracted; management command delegates to it.
  • Admin action visible on the ExternalIdentifierProperty changelist.
  • Confirmation page shown before execution.
  • Result summary (created/updated/unchanged/duration) displayed in admin message on completion.
  • Concurrent-run guard in place.
  • Tests cover the service function; admin action has at least a smoke test.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestenrichmentEnrichment provider system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions