From 475aeb9fabb344be8890e9e176853457d0bd1a7c Mon Sep 17 00:00:00 2001 From: Charlie Tonneslan Date: Sun, 17 May 2026 20:04:22 -0400 Subject: [PATCH] Clear stale wikipedia_bio rows where the URL is gone Person.save already clears wikipedia_bio when wikipedia_url is blank, but rows that haven't been resynced since the URL was removed on YNR still have the old extract sitting in the database. Have the daily import_wikipedia_bios command sweep them up at the end. Refs #2319 Signed-off-by: Charlie Tonneslan --- .../people/management/commands/import_wikipedia_bios.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/wcivf/apps/people/management/commands/import_wikipedia_bios.py b/wcivf/apps/people/management/commands/import_wikipedia_bios.py index ffc8e1bb0..1c4b31dfa 100644 --- a/wcivf/apps/people/management/commands/import_wikipedia_bios.py +++ b/wcivf/apps/people/management/commands/import_wikipedia_bios.py @@ -36,6 +36,14 @@ def update_people(self, current): except RequestException: pass + # Clear bios that were imported from a Wikipedia URL that's since been + # removed on YNR. New saves already trigger Person.save's url-aware + # clear, but rows that haven't been resynced since the URL was dropped + # still have stale text hanging around (see #2319). + Person.objects.filter( + wikipedia_url__isnull=True, wikipedia_bio__isnull=False + ).update(wikipedia_bio=None) + def update_ballots(self, current): parl_ballots = PostElection.objects.filter( ballot_paper_id__startswith="parl."