Skip to content

Add an update mode to the AniList import - #1801

Draft
AlgusDark wants to merge 2 commits into
FuzzyGrim:devfrom
AlgusDark:feat/import-update-mode
Draft

AlgusDark wants to merge 2 commits into
FuzzyGrim:devfrom
AlgusDark:feat/import-update-mode

Conversation

@AlgusDark

@AlgusDark AlgusDark commented Nov 6, 2026 •

Copy link
Copy Markdown

Closes #1800

Why

Periodic AniList imports have no mode that treats AniList as the source of truth. "Overwrite" deletes and recreates every entry, so undated entries show up in Activity History as added on every run. "New" only fills empty fields and moves status and progress forward, so a paused, dropped, or rescored entry never changes. This PR adds an "update" mode. It changes existing entries in place, only when AniList differs, and dates the change with AniList's updatedAt.

What changed

  • update_existing_media and update_existing_entries in integrations/imports/helpers.py sit beside their "new" mode counterparts. They compare status, progress, score, start date, end date, and notes, and set only the fields that differ. The history record gets AniList's updatedAt, and so does progressed_at when progress changed. If Yamtrack already has a record at that time or later, the update is dated now, so the history page still diffs records in order. The rows go through the existing bulk_update_media, so Media.save() never runs.
  • AniListImporter loads existing entries in every mode except overwrite and calls the update helper in "update" mode. Missing media and missing repeats are created as in "new" mode, and nothing is deleted. The delete, create, and update writes now run in one transaction.
  • The import settings list "Sync New Items and Update Existing (AniList only)", and scheduled imports show "Update Existing". import_media raises a MediaImportError when another importer gets "update", so the results page shows the reason.

Scope

  • Only AniList supports "update". Another importer adopts it by calling the new helpers and joining UPDATE_MODE_IMPORTERS in integrations/tasks.py.
  • Repeats work like "new" mode. When AniList has more entries (repeat + 1) than Yamtrack, the existing current entry becomes a finished repeat. It gets the Completed status, the episode or chapter count, and AniList's score and notes. It keeps its dates, because AniList only has the dates of the newest run. The missing entries are created after it. Yamtrack entries beyond AniList's count stay.
  • A run that only updates entries still reports "No media was imported.", as "new" mode does today. Counting updates changes the result message for every importer, so I left it for a follow-up.

Tradeoffs

  • The option is not hidden for other sources. All sources share one mode select, and disabling it on ten import cards adds more template code than the feature. A schedule with "update" for another source fails on its first run with the message above.

Verification

  • uv run manage.py test app users integrations lists events ran 882 tests, including 7 new ones, with Playwright Chromium installed. 881 pass. The one failure is an OpenLibrary metadata test that passes alone and flakes the same way on dev. ruff check and ruff format --check pass.
  • A disposable test imported a real public AniList list of 1,154 manga in overwrite mode and then ran "update". The update created no rows and wrote no history. After I raised progress on 3 entries, the next run wrote exactly 3 history rows, each dated with the edited updatedAt.
  • Mutation checks confirm the tests catch breakage. A plain == score comparison fails the no-history test, because Decimal("7.3") != 7.3. The new history-date, transaction, and update-path tests each fail when their code is removed.

In "update" mode, existing anime and manga take the AniList values in
place. An entry that matches AniList gets no write and no history
record. A changed entry gets one history record dated with AniList's
updatedAt. Missing media and repeats are created as in "new" mode, and
nothing is deleted.
Add the mode to the import mode list and label it in scheduled imports.
Imports from other sources fail in update mode with a clear message
until they support it.

This branch has not been deployed

No deployments
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.

[Feature Request] Import mode that updates existing entries in place (for periodic imports)

1 participant