Page MenuHomePhabricator

categorymembers (list module) new parameter request
Closed, ResolvedPublic

Description

Author: thecentercannothold

Description:
Two questions from a conversation over at Wikipedia willage pump (technical):

  1. is it possible to add parameters to the categorymembers query - say, 'cmstartsorted' and 'cmendsorted' - that will give a list of pages between page X and page Y according to the category's sort order? currently, we can only get ranges of pages according to timestamps.
  1. could those parameters also take ascending/descending arguments? the original question was whether there was a way to find immediate neighbors in the category to a category member (which is currently possible for later members by tricking the query-continue element, but not for previous members).

so, something like:

api?action=query&list=categorymembers&cmstartsorted=pagename1&cmendsorted=pagename2

would give all the category members between pagename1 and pagename2, whereas something like

api?action=query&list=categorymembers&cmstartsorted=pagename1&cmdir=desc

would give a list of category members starting at pagename1 and descending according to sort order

while we're at it, it's not at all clear what timestamps above refer to: the date the pages were last edited? the date the pages were added to the category? if you could clarify that, I'll add it to the API documentation.


Version: unspecified
Severity: enhancement

Details

Reference
bz15995

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:19 PM
bzimport set Reference to bz15995.

(In reply to comment #0)

Two questions from a conversation over at Wikipedia willage pump (technical):

  1. is it possible to add parameters to the categorymembers query - say,

'cmstartsorted' and 'cmendsorted' - that will give a list of pages between page
X and page Y according to the category's sort order? currently, we can only
get ranges of pages according to timestamps.

  1. could those parameters also take ascending/descending arguments? the

original question was whether there was a way to find immediate neighbors in
the category to a category member (which is currently possible for later
members by tricking the query-continue element, but not for previous members).

so, something like:

api?action=query&list=categorymembers&cmstartsorted=pagename1&cmendsorted=pagename2

would give all the category members between pagename1 and pagename2, whereas
something like

api?action=query&list=categorymembers&cmstartsorted=pagename1&cmdir=desc

would give a list of category members starting at pagename1 and descending
according to sort order

That's definitely possible, and already being done behind scenes to some extent by cmcontinue.

while we're at it, it's not at all clear what timestamps above refer to: the
date the pages were last edited? the date the pages were added to the category?
if you could clarify that, I'll add it to the API documentation.

I have absolutely no idea.

Bryan.TongMinh wrote:

(In reply to comment #1)

while we're at it, it's not at all clear what timestamps above refer to: the
date the pages were last edited? the date the pages were added to the category?
if you could clarify that, I'll add it to the API documentation.

I have absolutely no idea.

The time LinksUpdate triggered a change in category. This is usually when the category is added to the page, but I don't know whether the job queue and purging while being in the job queue has influence on this.

(In reply to comment #2)

(In reply to comment #1)

while we're at it, it's not at all clear what timestamps above refer to: the
date the pages were last edited? the date the pages were added to the category?
if you could clarify that, I'll add it to the API documentation.

I have absolutely no idea.

The time LinksUpdate triggered a change in category. This is usually when the
category is added to the page, but I don't know whether the job queue and
purging while being in the job queue has influence on this.

Is this timestamp updated every time LinksUpdate purges a page, or only under certain conditions?

Bryan.TongMinh wrote:

(In reply to comment #3)

(In reply to comment #2)

(In reply to comment #1)

while we're at it, it's not at all clear what timestamps above refer to: the
date the pages were last edited? the date the pages were added to the category?
if you could clarify that, I'll add it to the API documentation.

I have absolutely no idea.

The time LinksUpdate triggered a change in category. This is usually when the
category is added to the page, but I don't know whether the job queue and
purging while being in the job queue has influence on this.

Is this timestamp updated every time LinksUpdate purges a page, or only under
certain conditions?

Only when the category changes. But that's all from head, I should look it up to give a definite answer.

thecentercannothold wrote:

when will this be implemented? I just tried the following as a test:

api.php?format=jsonfm&action=query&list=categorymembers&cmtitle=Category:States%20of%20the%20United%20States&cmsort=sortkey&cmstartsortkey=Alabama

and it seemed not to have any effect. It didn't throw an error, mind you, so it recognizes the parameter, but the output I got (see below) definitely didn't start with Alabama.

{
"query-continue": {

		"categorymembers": {
			"cmcontinue": "Arizona|"
		}

},
"query": {

		"categorymembers": [
			{
				"pageid": 3382464,
				"ns": 14,
				"title": "Category:Fictional U.S. states"
			},
			{
				"pageid": 5760442,
				"ns": 14,
				"title": "Category:United States interstate compacts"
			},
			{
				"pageid": 18618239,
				"ns": 0,
				"title": "U.S. state"
			},
			{
				"pageid": 5805863,
				"ns": 14,
				"title": "Category:States of the United States related lists"
			},
			{
				"pageid": 15012635,
				"ns": 14,
				"title": "Category:Proposed states and territories of the United States"
			},
			{
				"pageid": 1055166,
				"ns": 14,
				"title": "Category:Categories by state of the United States"
			},
			{
				"pageid": 303,
				"ns": 0,
				"title": "Alabama"
			},
			{
				"pageid": 705602,
				"ns": 14,
				"title": "Category:Alabama"
			},
			{
				"pageid": 624,
				"ns": 0,
				"title": "Alaska"
			},
			{
				"pageid": 702716,
				"ns": 14,
				"title": "Category:Alaska"
			}
		]

}
}

Bryan.TongMinh wrote:

When somebody updates the Wikimedia servers. Which maybe within hours, or after the weekend, or later.

(In reply to comment #6)

when will this be implemented? I just tried the following as a test:

api.php?format=jsonfm&action=query&list=categorymembers&cmtitle=Category:States%20of%20the%20United%20States&cmsort=sortkey&cmstartsortkey=Alabama

and it seemed not to have any effect.

That's because I only fixed it today, and the fix hasn't gone live at Wikipedia yet. It won't go live over the weekend either, probably some time next week.

It didn't throw an error, mind you, so
it recognizes the parameter, but the output I got (see below) definitely didn't
start with Alabama.

Bogus parameters don't cause errors. Bogus values for parameters that only accept certain values do.

thecentercannothold wrote:

hey guys, this is the modern world: we expect IMMEDIATE gratification in all things. at least, that's what I keep telling my girlfriend...

thanks for the clarifications. :-)