Jump to content

User:SQL/FA-Ores/getOres

From Wikipedia, the free encyclopedia
function getOres( $revids ) {
	$revq = "revids=";
	$num = count( $revids );
	$passed = 0;
	foreach( $revids as $revid ) {
		$revq .= $revid;
		if( $passed < $num - 1 ) { $revq .= "|"; }
		$passed++;
	}
	$oresbase = "https://ores.wikimedia.org/v3/scores/enwiki/?models=wp10&$revq";
	$oresresult = json_decode( file_get_contents( $oresbase ), TRUE );
	$class = array();
	foreach( $revids as $page=>$revid ) {
		$oresOut = $oresresult['enwiki']['scores'][$revid]['wp10']['score']['prediction'];
		$class[$page] = $oresOut;
	}
	return( $class );
}

Query:

SELECT DISTINCT page_title, 
                page_latest 
FROM   categorylinks 
       JOIN page 
         ON page_id = cl_from 
WHERE  page_namespace = 1 
       AND cl_type = "page" 
       AND cl_to LIKE "Unassessed%rticles";