Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 7 additions & 30 deletions src/Model/TopEdits.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,36 +171,13 @@ public function getNumTopEdits(): int
*/
public function getProjectTotals(int $ns): array
{
if ($this->getNumPagesNamespace() > $this->limit) {
$projectTotals = $this->repository->getProjectTotals(
$this->project,
$this->user,
$ns,
$this->start,
$this->end
);
} else {
$counts_tmp = [];
// List of pages for this namespace
$rows = $this->topEdits[$ns];
foreach ($rows as $row) {
$num = $row["count"];
// May be null or nonexistent for assessment-less pages
$titles = $row["pap_project_title"] ?? "{}";
// Had to use json to pass multiple values in SQL select
foreach (json_decode($titles) as $projectName) {
$counts_tmp[$projectName] ??= 0;
$counts_tmp[$projectName] += $num;
}
}
arsort($counts_tmp);
$counts_tmp = array_slice($counts_tmp, 0, 10);
$projectTotals = [];
foreach ($counts_tmp as $project => $count) {
$projectTotals[] = [ "pap_project_title" => $project, "count" => $count ];
}
}
return $projectTotals;
return $this->repository->getProjectTotals(
$this->project,
$this->user,
$ns,
$this->start,
$this->end
);
}

/**
Expand Down
24 changes: 1 addition & 23 deletions src/Repository/TopEditsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,6 @@ public function getTopEditsNamespace(
LIMIT 1
) AS pa_class"
: '';
$paProjectsTable = $project->getTableName('page_assessments_projects');
$paProjectsSelect = $hasPageAssessments
? ", (
SELECT JSON_ARRAYAGG(pap_project_title)
FROM $paTable
JOIN $paProjectsTable
ON pa_project_id = pap_project_id
WHERE pa_page_id = page_id
) AS pap_project_title"
: '';

$ipcJoin = '';
$whereClause = 'rev_actor = :actorId';
Expand All @@ -147,7 +137,6 @@ public function getTopEditsNamespace(
$sql = "SELECT page_namespace AS `namespace`, page_title,
page_is_redirect AS `redirect`, COUNT(page_title) AS `count`
$paSelect
$paProjectsSelect
FROM $pageTable

JOIN $revisionTable ON page_id = rev_page
Expand Down Expand Up @@ -309,17 +298,6 @@ public function getTopEditsAllNamespaces(
LIMIT 1
) AS pa_class"
: '';
$paProjectsTable = $project->getTableName('page_assessments_projects');
$paProjectsSelect = $hasPageAssessments
? ", (
SELECT JSON_ARRAYAGG(pap_project_title)
FROM $pageAssessmentsTable
JOIN $paProjectsTable
ON pa_project_id = pap_project_id
WHERE pa_page_id = e.page_id
) AS pap_project_title"
: '';


$ipcJoin = '';
$whereClause = 'rev_actor = :actorId';
Expand All @@ -332,7 +310,7 @@ public function getTopEditsAllNamespaces(
}

$sql = "SELECT c.page_namespace AS `namespace`, e.page_title,
c.page_is_redirect AS `redirect`, c.count $paSelect $paProjectsSelect
c.page_is_redirect AS `redirect`, c.count $paSelect
FROM
(
SELECT b.page_namespace, b.page_is_redirect, b.rev_page, b.count
Expand Down
6 changes: 3 additions & 3 deletions templates/topedits/result_namespace.wikitext.twig
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
|}
{% if showPageAssessment %}
{% set totals = te.projectTotals(ns) %}
{% if totals|keys|length > 0 %}
{% if totals|length > 0 %}
{| class="wikitable sortable"
|+ {{ msg('top-wikiprojects') }}
! {{ msg('wikiproject') }} !! {{ msg('count') }}
{% for wikiproject, count in totals %}
{% for row in totals %}
|-
| {{ wikiproject }} || {{ count|num_format }}
| {{ row.pap_project_title }} || {% verbatim %}{{FORMATNUM:{% endverbatim %}{{ row.count }}}}
{% endfor %}
|}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion tests/Model/PageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function testUsersEdits(): void
*/
public function testErrors(): void
{
$this->markTestSkipped( 'Broken until T413013 is fixed' );
$this->markTestSkipped('Broken until T413013 is fixed');
$checkWikiErrors = [
[
'error' => '61',
Expand Down
Loading