Page MenuHomePhabricator

Create new API endpoint for edit-to-event association with queue processing
Closed, ResolvedPublic

Assigned To
Authored By
cmelo
Aug 5 2025, 2:47 PM
Referenced Files
Restricted File
Oct 31 2025, 11:36 PM
Restricted File
Oct 31 2025, 11:34 PM
Restricted File
Oct 31 2025, 11:34 PM
Restricted File
Oct 31 2025, 11:34 PM
Restricted File
Oct 31 2025, 11:34 PM
F68985831: Screenshot 2025-10-31 at 6.18.59โ€ฏPM.png
Oct 31 2025, 11:26 PM

Description

Create a new endpoint that receives edit data and sends messages to a queue for background processing.

The API should:

  • Accept PUT requests with revisionId, wikiId and eventId
  • Validate that the user has the specified event as an ongoing event
  • Process the association via the JobQueue and not synchronously
  • Return success response indicating the request was queued for processing
  • Handle validation errors and return appropriate error messages
  • Be documented

BDD

Feature: Associate edit to event via queue processing

  Scenario: Successfully queue edit association
    Given a user has an ongoing event
    And the user has made an edit
    When the API is called with valid edit data
    Then a message is sent to the queue
    And a success response is returned
    And the response indicates processing is queued

  Scenario: User does not have ongoing event
    Given a user does not have the specified event as ongoing
    When the API is called with the event data
    Then an error response is returned
    And no message is sent to the queue
    And the error indicates invalid event participation

  Scenario: Event is no longer ongoing
    Given an event has ended
    And the user was a participant
    When the API is called with the event data
    Then an error response is returned
    And no message is sent to the queue
    And the error indicates event is not ongoing

  Scenario: Invalid timestamp (too old)
    Given the edit timestamp is outside the allowed time window
    When the API is called with the edit data
    Then an error response is returned
    And no message is sent to the queue
    And the error indicates timestamp is invalid

  Scenario: API validates using cache -> TBD see https://phabricator.wikimedia.org/T401211 for more details
    Given the cache contains user event data
    When the API is called with event data
    Then validation is performed using cache data
    And no database queries are performed for validation

Event Timeline

cmelo changed the task status from Open to In Progress.Aug 14 2025, 7:01 PM
cmelo claimed this task.

Change #1179179 had a related patch set uploaded (by Cmelo; author: Cmelo):

[mediawiki/extensions/CampaignEvents@master] Add REST API endpoint for associating edits to events (T401208)

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

Change #1181828 had a related patch set uploaded (by Cmelo; author: Cmelo):

[mediawiki/extensions/CampaignEvents@master] Add REST API endpoint for associating edits to events

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

Change #1182151 had a related patch set uploaded (by Cmelo; author: Cmelo):

[mediawiki/extensions/CampaignEvents@master] Add REST API endpoint for associating edits to events

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

Change #1182151 abandoned by Cmelo:

[mediawiki/extensions/CampaignEvents@master] Add REST API endpoint for associating edits to events

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

Change #1182864 had a related patch set uploaded (by Cmelo; author: Cmelo):

[mediawiki/extensions/CampaignEvents@master] Add new feature flag for contribution tracking

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

Change #1182864 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Add new feature flag for contribution tracking

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

Change #1181828 abandoned by Daimona Eaytoy:

[mediawiki/extensions/CampaignEvents@master] Add REST API endpoint for associating edits to events

Reason:

Duplicate of I1d25645fe927269

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

Test wiki created on Patch demo by CMelo (WMF) using patch(es) linked to this task:
https://554fabc3ca.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by CMelo (WMF) using patch(es) linked to this task:
https://27a4ec2259.catalyst.wmcloud.org/w/

Test wiki on Patch demo by CMelo (WMF) using patch(es) linked to this task was deleted:

https://554fabc3ca.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by CMelo (WMF) using patch(es) linked to this task:
https://ce2d28a2bc.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by CMelo (WMF) using patch(es) linked to this task:
https://2b7ac98b54.catalyst.wmcloud.org/w/

Test wiki on [[ | Patch demo ]] by CMelo (WMF) using patch(es) linked to this task was deleted:

https://2b7ac98b54.catalyst.wmcloud.org/w/

Test wiki created on Patch demo by CMelo (WMF) using patch(es) linked to this task:
https://c55106d465.catalyst.wmcloud.org/w/

Test wiki on Patch demo by CMelo (WMF) using patch(es) linked to this task was deleted:

https://c55106d465.catalyst.wmcloud.org/w/

Change #1179179 merged by jenkins-bot:

[mediawiki/extensions/CampaignEvents@master] Add REST API endpoint for associating edits to events

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

vaughnwalters subscribed.

The API should:

โœ… Accept PUT requests with revisionId, wikiId and eventId
โŒ Validate that the user has the specified event as an ongoing event QA Note API does not validate that event has already started and can currently associate an edit with events that have not yet started. Created follow up task T408960
โ“ Validate that the event is still ongoing within a reasonable time window QA Note: I am unsure what a "reasonable time window" means?" This does validate that the event has not yet ended, so maybe that is all that is needed?

Screenshot 2025-10-31 at 6.18.59โ€ฏPM.png (986ร—1 px, 170 KB)

โœ… Process the association via the JobQueue and not synchronously
โœ… Return success response indicating the request was queued for processing QA Note: Responds with a 202 Accepted
โœ… Handle validation errors and return appropriate error messages
QA Note: A few error states:

{F68986708}{F68987044}{F68987168}{F68987291}{F68987463}

โœ… Be documented


I created a followup task for the second AC, so the only remaining question I have for dev is about the "reasonable time window" above.

Thank you!

  • The following AC has been removed so it is no longer valid: " Validate that the event is still ongoing within a reasonable time window"
  • T408960 has been taken on.

For these reasons, I think all issues have been resolved, so moving back to QA for a final okay.

Thank you!

  • The following AC has been removed so it is no longer valid: " Validate that the event is still ongoing within a reasonable time window"
  • T408960 has been taken on.

For these reasons, I think all issues have been resolved, so moving back to QA for a final okay.

Thank you @ifried - with these changes, AC is met and I am moving this to product sign off