Page MenuHomePhabricator

Create database structure to store edit-to-event associations
Closed, ResolvedPublic3 Estimated Story Points

Description

Background

Design and create a new database table to persist information about edits that users explicitly associate with an ongoing event. This table will be used later to compute collaboration metrics and populate the new event summary view.

We will represent bytes as one number for the MVP. So, for example, if someone removed 1000 bytes and added 100 bytes, we will show that they removed 900 bytes. This decision was reached because a) this is how it is represented on the wikis now and therefore how editors are accustomed to understanding and interpreting the numbers, and b) this is a simpler solution, and we have an upcoming MVP deadline.

We will count all edits made by an editor and associated with an event as a valid edit. This could include things like reverts, as long as they use the source editor/VE.

Page references will be stored as full page titles, similar to the campaign_events table. This is because we need to store pages cross-wiki, so:

  • Storing a page ID won't give us the text to show in the contributions summary (unless we also query the page table for each involved DB, oof)
  • There's no reliable way to go from namespace ID + title to a full prefixedtitle for foreign pages (namespace resolution is based on config, and we can't read config cross-wiki, see T226667 & related tasks)

We will additionally store the page ID so that the row can easily be updated in case of page moves and deletions (T403200)

In the future, we will also want to probably support other data points, post-MVP. Other potential data points can be fond in this spreadsheet and will later be converted into Phabricator tickets.

Acceptance Criteria
  • A new database table is created that tracks at least the following:
    • Event ID
    • Page title
    • Page ID
    • Revision ID
    • User ID
    • Wiki ID
    • Bytes delta
    • Internal links delta
    • Whether the edit is also a page creation
    • Timestamp of the edit
    • Whether the edit is visible (i.e. page still exists, revision not deleted)

Checklist

  • Design the schema
  • Make schema change patch for it
  • Get initial reviews (+1s)
  • Request DBA signoff: T402659
  • Get approval
  • Catalog the table
Deployment
  • Merge the schema patch
    • This will automatically create the new table in beta
  • Wait until the patch reaches production
  • Schedule a dedicated deployment window, note the time here
  • Create the table everywhere:
    • mwscript sql.php --wiki=testwiki --cluster=extension1 /srv/mediawiki/php-1.45.0-wmf.18/extensions/CampaignEvents/db_patches/mysql/patch-add-ce_event_contributions.sql
    • mwscript sql.php --wiki=test2wiki --cluster=extension1 /srv/mediawiki/php-1.45.0-wmf.18/extensions/CampaignEvents/db_patches/mysql/patch-add-ce_event_contributions.sql
    • mwscript sql.php --wiki=officewiki --cluster=extension1 /srv/mediawiki/php-1.45.0-wmf.18/extensions/CampaignEvents/db_patches/mysql/patch-add-ce_event_contributions.sql
    • mwscript sql.php --wiki=metawiki --cluster=extension1 --wikidb wikishared /srv/mediawiki/php-1.45.0-wmf.18/extensions/CampaignEvents/db_patches/mysql/patch-add-ce_event_contributions.sql

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptJul 29 2025, 2:56 PM
cmelo renamed this task from Draft: Create database structure to store edit-to-event associations to Create database structure to store edit-to-event associations.Jul 30 2025, 4:44 PM
cmelo updated the task description. (Show Details)
cmelo set the point value for this task to 3.

I discussed the question of links with @Sadads, and decisions include:

  • We only need links added (not removed) for MVP
  • Links = internal links (not external links)

Note that we may later want a separate metric for external links (especially if we find it hard to get reference data), but that would be a separate metric for later consideration.

cmelo updated the task description. (Show Details)

Change #1176227 had a related patch set uploaded (by Mhorsey; author: Mhorsey):

[mediawiki/extensions/CampaignEvents@master] Add new DB schema to associate edit with an event

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

One thing we discussed this week but was not documented (anywhere that I could find): all queries to this table will probably involve a join with ce_participants. In some cases, this is to filter out contributions from private participants. But even when that is not a concern, we do need to filter out deleted participants (non-null cep_unregistered_at). Something to keep in mind especially when considering indices.

Change #1184501 had a related patch set uploaded (by Daimona Eaytoy; author: Daimona Eaytoy):

[operations/puppet@production] tables-catalog: Document ce_event_contributions (CampaignEvents)

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

Change #1176227 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Add new DB schema to associate edit with an event

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

Change #1184501 merged by Ladsgroup:

[operations/puppet@production] tables-catalog: Document ce_event_contributions (CampaignEvents)

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

Daimona updated the task description. (Show Details)
Daimona updated the task description. (Show Details)

Mentioned in SAL (#wikimedia-operations) [2025-09-17T12:03:52Z] <Daimona> Creating new tables for the CampaignEvents extension in x1.testwiki, x1.test2wiki, x1.officewiki, and x1.wikishared # T400719

vaughnwalters subscribed.

From wikishared:

FieldTypeNullKeyDefaultExtra
cec_idbigint(20) unsignedNOPRIauto_increment
cec_event_idbigint(20) unsignedNOMUL
cec_user_idbigint(20) unsignedNO
cec_wikivarbinary(64)NOMUL
cec_page_idint(10) unsignedNO
cec_page_prefixedtextvarbinary(512)NO
cec_revision_idbigint(20) unsignedNO
cec_edit_flagsint(11)NO
cec_bytes_deltaint(11)NO
cec_links_deltasmallint(6)NO
cec_timestampbinary(14)NO
cec_deletedtinyint(1)NO

Acceptance Criteria
A new database table is created that tracks at least the following:
โœ… Event ID -> cec_event_id
โœ… Page title -> cec_page_prefixedtext
โœ… Page ID -> cec_page_id
โœ… Revision ID -> cec_revision_id
โœ… User ID -> cec_user_id
โœ… Wiki ID -> cec_wiki
โœ… Bytes delta -> cec_bytes_delta
โœ… Internal links delta -> cec_links_delta
โœ… Whether the edit is also a page creation -> cec_edit_flags
โœ… Timestamp of the edit -> cec_timestamp
โœ… Whether the edit is visible (i.e. page still exists, revision not deleted) -> cec_deleted

AC is met, so I am sending this to product sign off