Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit fc8b10e

Browse files
committed
further on mediawiki query builder
1 parent cf8659a commit fc8b10e

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

includes/data/query/MediaWiki.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,28 @@ private function getMediaWikiVersionInfo( string $version, int $limit, DBConnRef
4040
$version3 = false;
4141
$where = false;
4242
if ( isset( $explodedVersions[0] ) ) {
43-
$where .= $explodedVersions[0] . '.';
43+
$where .= $explodedVersions[0];
4444
}
4545
if ( isset( $explodedVersions[1] ) ) {
46-
$where .= $explodedVersions[1] . '.';
46+
$where .= '.' . $explodedVersions[1];
4747
}
4848
if ( isset( $explodedVersions[2] ) ) {
49-
$where .= $explodedVersions[2] . '.';
49+
$where .= '.' . $explodedVersions[2];
5050
}
51-
$where = substr( $where, 0, -1 );
5251
$where = [ Structure::SCRAPE_MEDIAWIKI_VERSION => $where ];
53-
$select = [ Structure::SCRAPE_MEDIAWIKI_VERSION,
52+
$select = [ Structure::SCRAPE_MEDIAWIKI_VERSION, Structure::SR_ID,
5453
'count' => 'count(*)' ];
5554
$from = Structure::DBTABLE_SCRAPE;
56-
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->wh->groupBy( 'w8y_ex_name' )
57-
->orderBy( 'count',
55+
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->where( $where )->
56+
groupBy( Structure::SCRAPE_MEDIAWIKI_VERSION )->orderBy( 'count',
5857
'DESC' )->limit( $limit )->caller( __METHOD__ )->fetchResultSet();
5958
$ret = [];
6059
$t = 0;
6160
if ( $res->numRows() > 0 ) {
6261
while ( $row = $res->fetchRow() ) {
6362
$ret[$t]['Count'] = $row['count'];
64-
foreach ( $this->structure->returnTableColumns( Structure::DBTABLE_EXTENSIONS ) as $tName ) {
65-
$ret[$t][$tName] = $row[$tName];
66-
}
63+
$ret[$t]['version'] = $row[ Structure::SCRAPE_MEDIAWIKI_VERSION ];
64+
$ret[$t]['sid'] = $row[ Structure::SR_ID ];
6765
$t++;
6866
}
6967
}
@@ -79,6 +77,11 @@ private function getMediaWikiVersionInfo( string $version, int $limit, DBConnRef
7977
* @return mixed
8078
*/
8179
public function doQuery( string $version, int $limit = 10, string $export = "table" ): mixed {
80+
/*
81+
* MediaWiki version - given major version:
82+
• also major/minor/special versions associated with major version
83+
• list of wikis actively using with version
84+
*/
8285
$lb = MediaWikiServices::getInstance()->getDBLoadBalancer();
8386
$dbr = $lb->getConnectionRef( DB_REPLICA );
8487
$result = [];

0 commit comments

Comments
 (0)