Page MenuHomePhabricator

Sort results from TemporaryAccountHandler by timestamp
Closed, ResolvedPublic

Description

Background

See also T324603#8584676.

We should sort the returned IPs by timestamp, since we want the most recent IP addresses wherever we hit a limit. If the actor has very many rows, this could lead to a slow query (there's no index on cuc_actor, cuc_timestamp, so a sort will probably have to be performed).

However, in 90 days hopefully an actor won't accumulate that many rows. We can also monitor API performance: T328892: Monitor the performance of TemporaryAccountHandler APIs.

Acceptance criteria
  • IP addresses returned for a given temporary account are sorted by timestamp (most recent first)
Testing Notes
  • You can tweak the code(For debugging purposes only and should be removed from the final code.!!) to return all the timestamps for each IP address, you can modify the code to include the timestamps in the result set and then return that result set in the 'getData' function. e.g : 'timestamp' => $row->cuc_timestamp ;

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptFeb 6 2023, 4:59 AM

Change 888647 had a related patch set uploaded (by Cyndywikime; author: Cyndywikime):

[mediawiki/extensions/CheckUser@master] Sort results from TemporaryAccountHandler by timestamp

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

Change 888647 merged by jenkins-bot:

[mediawiki/extensions/CheckUser@master] Sort results from TemporaryAccountHandler by timestamp

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

dom_walden subscribed.

I used a script to compare the output of the API with querying the database.

I did this on sqlite, mysql and postgresql.

I found that the order was inconsistent if I applied different limit parameters. I assume if there are multiple IPs with the same timestamp the order they are returned might vary from query to query. This happened with mysql and postgresql but not sqlite.

Perhaps in T328894 we should also sort by cuc_ip to make it consistent.

Test environment: local environments CheckUser 2.5 (6a7df60) 07:55, 17 February 2023.

  • sqlite 3.34.1
  • mariadba 10.5.18
  • postgresql 13