Page MenuHomePhabricator

Implement the first pass of a maintenance script that supports preference updates for consenting donors
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

As part of the donor identification project we will need a script that can parse a CSV file exported by CiviCRM and translate it into user preferences. This work will build on the preference added in T416946: Add a preference for receiving donor information from CiviCRM and the export provided by T416948: CiviCRM should export a CSV that can be used in a MediaWiki maintenance script to update the user preference table based on the contents of the CSV file.

User story

As a user who has consent donor identification I want MediaWiki have awareness of how recently I last donated so that it can tailor my experience accordingly.

Requirements

The script will process every file in the provided CSV as follows:

  • If the e-mail address does not correspond with any user in the user table, the row will be discarded.
  • If the e-mail address corresponds with a user who has not consented to donor identification the row will be discarded.
  • If the e-mail address corresponds with a user that has not confirmed their email address the row will be discarded.
  • If the email address corresponds with a user that has confirmed their email address and given consent, a donor preference will be derived from the donor segment provided by the CSV. For now derive this by function (a) => a but see assumptions section that this will change in future. This will override any existing value.
  • After the CSV has been fully processed, the CSV will be discarded (or will notify an external service that this has been done)
  • The script takes a dry-run parameter to allow us to update
  • The script should be able to handle large CSVs e.g. 1 million rows. If you run into issues with this please document those (it is okay to handle them in a follow up task)
  • Never output email addresses to the logs

Donor segment updating

  • For the initial pass we'll set the donor preference to the value in the CSV but the solution should allow for change to this logic in future. For example we may decide to set the user preference to 2 for all donors before going live for privacy purposes. Make sure the script is flexible to support mapping the values to other values in future.

Assumptions

  • You can assume the job will be run automatically.
  • You can assume that will not be running the job until further review (feel free to merge something incomplete or defer merging the patch to a later task)
  • you can assume the CSV does not contain duplicate rows (e.g. the email address is unique for each row)
  • You can assume an SRE review will occur prior to use in a production environment
  • You can assume T416946: Add a preference for receiving donor information from CiviCRM is or will be soon resolved.
  • You can assume that the CSV will contain rows in the form x@x.com,300 (but please verify that against the work in T416948: CiviCRM should export a CSV that can be used in a MediaWiki maintenance script)
  • Assume that we will need to map the donor segment numbers in the CSV to another number by a function that it yet to be determined. For the first version it is fine to use as is as we just want to demonstrate the solution works end to end.
  • You can assume the preference has already been added e.g. the gerrit patch here has been merged.

BDD

  • For QA engineer to fill out

Test Steps

  • For QA engineer to fill out

Design

  • Add mockups and design requirements

Acceptance criteria

  • We have an unmerged patch that is capable of parsing the file exported by CiviCRM
  • We have an understanding of how this script would fare processing thousands/millions of rows (how will it batch).

Communication criteria - does this need an announcement or discussion?

  • Add communication criteria

Sign off

This task was created by Version 1.2.0 of the Web team task template using phabulous

Event Timeline

HFan-WMF set the point value for this task to 3.Feb 18 2026, 6:14 PM

Explicitly and formally a proof of concept ticket - no code will be merged, but this will give us something to talk about, and prove out the envisioned approach with local testing 🤞

Removing Jon as the assignee so anyone on Reader Experience can pick this up

Change #1248615 had a related patch set uploaded (by Stoyofuku-wmf; author: Stoyofuku-wmf):

[mediawiki/extensions/WikimediaMaintenance@master] Proof of Concept: script to sync donor status

https://gerrit.wikimedia.org/r/1248615

Got a working script up - remaining todos:

  • stream the file so we're not loading potentially 2GB into memory
  • spend some time thinking about batch processing/failure modes/atomic writes
  • add dry run functionality
  • proof of concept the tests bc otherwise they won't get written ):

For @Jdlrobson-WMF when he comes back:

  • let's confirm the architecture in terms of what the preferences look like and where they're getting saved/loaded from
  • we might need to spend a couple minutes thinking about the best way to design around 3 fields vs 1, especially if there is a possibility of additional ones being added

Proof of concept (w tests) added - some of the aforementioned features are missing, but don't feel the hardest to prove out. Jon and I should talk about batch processing/failure modes/atomic writes, as well as the structure of the data and stuff like local vs global users when he gets back

Change #1270555 had a related patch set uploaded (by Bernard Wang; author: Bernard Wang):

[mediawiki/extensions/WikimediaCustomizations@master] Add maintenance script to sync donor preference

https://gerrit.wikimedia.org/r/1270555

Change #1275487 had a related patch set uploaded (by Aude; author: Aude):

[integration/config@master] Zuul: [mediawiki/extensions/WikimediaCustomizations] Add CentralAuth dependency

https://gerrit.wikimedia.org/r/1275487

Change #1270555 merged by jenkins-bot:

[mediawiki/extensions/WikimediaCustomizations@master] Add maintenance script to sync donor preference

https://gerrit.wikimedia.org/r/1270555

Change #1248615 abandoned by Stoyofuku-wmf:

[mediawiki/extensions/WikimediaMaintenance@master] Proof of Concept: script to sync donor status

Reason:

If nothing else, I endorse my more recent approach above this patch (also a version of this was already merged)

https://gerrit.wikimedia.org/r/1248615