mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Editcount
synced 2024-11-27 09:42:28 +00:00
Editcount: Migrate to fluent style query
Change-Id: Ica309a5986aed42b04c5150d45376c629df01ac6
This commit is contained in:
parent
b7b699d9ac
commit
116bf43c5a
|
@ -9,7 +9,7 @@
|
|||
"license-name": "GPL-2.0-or-later",
|
||||
"type": "specialpage",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.32.0"
|
||||
"MediaWiki": ">= 1.36.0"
|
||||
},
|
||||
"SpecialPages": {
|
||||
"Editcount": "Editcount"
|
||||
|
|
|
@ -69,22 +69,24 @@ class Editcount extends IncludableSpecialPage {
|
|||
return [];
|
||||
}
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$actorWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $user );
|
||||
$res = $dbr->select(
|
||||
[ 'revision', 'page' ] + $actorWhere['tables'],
|
||||
[ 'page_namespace', 'COUNT(*) AS count' ],
|
||||
[ $actorWhere['conds'] ],
|
||||
__METHOD__,
|
||||
[ 'GROUP BY' => 'page_namespace' ],
|
||||
[ 'page' => [ 'JOIN', 'page_id = rev_page' ] ] + $actorWhere['joins']
|
||||
);
|
||||
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase();
|
||||
$actorNormalization = MediaWikiServices::getInstance()->getActorNormalization();
|
||||
$actorId = $actorNormalization->findActorId( $user, $dbr );
|
||||
$query = $dbr->newSelectQueryBuilder()
|
||||
->caller( __METHOD__ )
|
||||
->select( [ 'page_namespace', 'count' => 'COUNT(*)' ] )
|
||||
->from( 'revision' )
|
||||
->join( 'page', null, 'page_id = rev_page' )
|
||||
->join( 'actor', null, 'rev_actor = actor_id' )
|
||||
->where( [ "actor_id" => $actorId ] )
|
||||
->groupBy( 'page_namespace' );
|
||||
$res = $query->fetchResultSet();
|
||||
|
||||
$nscount = [];
|
||||
$nsCount = [];
|
||||
foreach ( $res as $row ) {
|
||||
$nscount[$row->page_namespace] = (int)$row->count;
|
||||
$nsCount[$row->page_namespace] = (int)$row->count;
|
||||
}
|
||||
return $nscount;
|
||||
return $nsCount;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,15 +101,16 @@ class Editcount extends IncludableSpecialPage {
|
|||
return 0;
|
||||
}
|
||||
|
||||
$dbr = wfGetDB( DB_REPLICA );
|
||||
$actorWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $user );
|
||||
return (int)$dbr->selectField(
|
||||
[ 'revision', 'page' ] + $actorWhere['tables'],
|
||||
'COUNT(*)',
|
||||
[ 'page_namespace' => $ns, $actorWhere['conds'] ],
|
||||
__METHOD__,
|
||||
[],
|
||||
[ 'page' => [ 'JOIN', 'page_id = rev_page' ] ] + $actorWhere['joins']
|
||||
);
|
||||
$dbr = MediaWikiServices::getInstance()->getDBLoadBalancerFactory()->getReplicaDatabase();
|
||||
$actorNormalization = MediaWikiServices::getInstance()->getActorNormalization();
|
||||
$actorId = $actorNormalization->findActorId( $user, $dbr );
|
||||
$query = $dbr->newSelectQueryBuilder()
|
||||
->caller( __METHOD__ )
|
||||
->select( 'COUNT(*)' )
|
||||
->from( 'revision' )
|
||||
->join( 'page', null, 'page_id = rev_page' )
|
||||
->join( 'actor', null, 'rev_actor = actor_id' )
|
||||
->where( [ "actor_id" => $actorId, "page_namespace" => $ns ] );
|
||||
return $query->fetchField();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue