Page MenuHomePhabricator

Watchlist expiry API: Add a expiry parameter when adding an item to the watchlist [medium]
Closed, ResolvedPublic

Description

As a Watchlist Expiry user, I want expiry parameters enabled when adding items to the watchlist via the API, so the feature can be accessed via the API.

Background: This ticket is for back-end work only.

Acceptance Criteria:

  • When adding an item to the watchlist through the API, add a parameter for expiry so the item can be added with an expiration.
  • Note: there is *one* expiry value allowed, even for bulk additions. Whatever is supplied, all added items will receive the same expiry value.

Event Timeline

Restricted Application added a project: archived--TCB-Team. · View Herald TranscriptFeb 13 2020, 12:08 AM
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
ifried updated the task description. (Show Details)Feb 13 2020, 5:07 PM
ifried updated the task description. (Show Details)Feb 13 2020, 5:35 PM
ifried updated the task description. (Show Details)Feb 13 2020, 5:51 PM
ifried renamed this task from Watchlist expiry API: Add a expiry parameter when adding an item to the watchlist to Watchlist expiry API: Add a expiry parameter when adding an item to the watchlist [medium].Feb 13 2020, 6:19 PM
ifried moved this task from To Be Estimated/Discussed to Estimated on the Community-Tech board.
Restricted Application edited projects, added Community-Tech; removed Community-Tech (Kanban-Q3-2019-20). · View Herald TranscriptFeb 13 2020, 6:55 PM

Change 572107 had a related patch set uploaded (by MusikAnimal; owner: MusikAnimal):
[mediawiki/core@master] [WIP] Introduce an expiry to WatchlistItem

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

I'm going to stop here and ask for feedback on my approach.

The biggest problem I see is that we're doing a multi-insert into the watchlist table, but we need the generated wl_ids in order to update watchlist_expiry. So, I guess we have to either switch to single inserts (and I think get the wl_id with Database::insertId()) or manually fetch the IDs before updating watchlist_expiry, maybe in a deferred update?

Other to-dos:

  • Make the hooks WatchArticle and WatchArticleComplete accept the expiry (though they don't have to make use of them)
  • Make method(s) to modify the expiry
  • ...
aezell added a subscriber: aezell.Feb 13 2020, 10:35 PM

This is a good question. My first instinct would be to do single inserts inside a database transaction.

I'll take a look at the code and see if something else jumps out.

MusikAnimal removed MusikAnimal as the assignee of this task.Feb 18 2020, 10:37 PM
MusikAnimal added a subscriber: MusikAnimal.

Unassiging until T245213 is resolved.

Mooeypoo updated the task description. (Show Details)Feb 26 2020, 9:34 PM

Change 580522 had a related patch set uploaded (by MusikAnimal; owner: MusikAnimal):
[mediawiki/core@master] [WIP] Add expiry support to Watch API

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

Change 580522 merged by jenkins-bot:
[mediawiki/core@master] ApiWatch: Add support for expiries

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

Change 583513 had a related patch set uploaded (by Samwilson; owner: Samwilson):
[mediawiki/core@master] Add release notes for recently-merged watchlist expiry work

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

dom_walden added a subscriber: dom_walden.

When using the Watch API:

  • When watching an item without setting the expiry parameter:
    • If the item is not watched, it is watched without an expiry
    • If the item is already watched with an expiry, the expiry is unchanged

The API response looks something like, showing the expiry time for the watched item:
{'batchcomplete': '', 'watch': [{'title': 'Foobar', 'ns': 0, 'expiry': '2020-03-30T14:44:32Z', 'watched': ''}]}

You can watch an item with a different expiry time, modifying the expiry time in the DB. If the expiry time is "infinite", the expiry is removed from the database.

Unwatching an item also removes the expiry from the DB, before and after it has expired.

You can also use generators to, for example, set the expiry time of all(?) the user's watched items to 1 minute, e.g. https://en.wikipedia.beta.wmflabs.org/wiki/Special:ApiSandbox#action=watch&format=json&expiry=1%20minute&generator=watchlistraw

Change 583513 merged by jenkins-bot:
[mediawiki/core@master] Add release notes for recently-merged watchlist expiry work

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

ifried closed this task as Resolved.May 28 2020, 3:44 PM
ifried moved this task from Product sign-off to Done on the Community-Tech (Kanban-2019-20-Q4) board.
ifried added a subscriber: ifried.

The work has been deployed. There is nothing directly user-facing to test here, and the changes have been tested by Dom. For this reason, I'm marking it as Done.