Skip to content
This repository was archived by the owner on Mar 20, 2026. It is now read-only.

Commit 7fb5a55

Browse files
authored
EditCounter: + approx autoedits count using tags (#532)
Added just above the small/large edits. Changes: - add `auto-edits-tagged` message for this - add a getTags method to autoeditshelper to just get the tag list - inject autoeditshelper into editcountercontroller and editcounter - get the revision tags in getEditSizeData in editcounterrepository - add an editcounter method to use getEditSizeData and getTags to get how many edits are automated in the last 5000 - add a row in the html table in general_stats.html.twig Bug: T342402
1 parent 2b224eb commit 7fb5a55

15 files changed

Lines changed: 134 additions & 45 deletions

assets/js/editcounter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ xtools.editcounter.setupMonthYearChart = function (id, datasets, labels, maxTota
317317
xtools.editcounter.setupSizeHistogram = function (data, colors, barLabels) {
318318
let bars = 11;
319319
// First sanitize input, to get array.
320-
let total = Object.keys(data).length - 3; // -3 to exclude small edits, large edits and average
320+
let total = Object.keys(data).length;
321321
data.length = total;
322322
data = Array.from(data)
323323
// Then make datasets

i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"auto-contribs-use-tool": "Show only edits using the tool:",
4141
"auto-edits": "(Semi-)automated edits",
4242
"auto-edits-bot": "This user is a bot. All edits may be automated. Statistics shown here are based on edits made using known tools.",
43+
"auto-edits-tagged": "Tagged (semi-)automated edits",
4344
"auto-edits-counts-desc": "Some tool usage overlaps (e.g. rolling back to a revision that is a redirect counts as Rollback and as Redirect), so the total of edits made with each tool may differ from the $1.",
4445
"auto-edits-counts-desc-grand-total": "grand total",
4546
"auto-edits-logged-out": "You must login to use the sandbox configuration. Using production configuration instead.",

i18n/qqq.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
"auto-contribs-use-tool": "Label for dropdown that limits results to edits made by the selected (semi-)automated tool. The dropdown is located immediately after the label.",
6060
"auto-edits": "(semi-)automated edits with known tools like Huggle",
6161
"auto-edits-bot": "Message shown at the top of the AutoEdits tool for users who are a bot, explaining that all edits made by the bot may be automated, even if XTools says they are not.",
62+
"auto-edits-tagged": "Label for the very approximate count of tagged (semi-)automated edits in the last 5000 edits in the Edit Counter.",
6263
"auto-edits-counts-desc": "In the AutoEdits tool, this message explains how the totals of individual tools (shown in the '(semi-)automated edits' section) may be different from the total shown in the 'Summary' section. $1 is a link to the 'Summary' section with the message 'auto-edits-counts-grand-total' as the link text.",
6364
"auto-edits-counts-desc-grand-total": "The text 'grand total'. This is used as the text for the link in the 'auto-edits-counts-desc' message.",
6465
"auto-edits-logged-out": "Message shown when the user attempts to use the AutoEdits tool in sandbox mode, but hasn't logged in.",

public/build/app.93b4ef2d.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/app.a92fcf1a.js

Lines changed: 0 additions & 2 deletions
This file was deleted.

public/build/entrypoints.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"js": [
55
"/build/runtime.c217f8c4.js",
66
"/build/852.96913092.js",
7-
"/build/app.a92fcf1a.js"
7+
"/build/app.93b4ef2d.js"
88
],
99
"css": [
1010
"/build/app.7692d209.css"

public/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"build/app.css": "/build/app.7692d209.css",
3-
"build/app.js": "/build/app.a92fcf1a.js",
3+
"build/app.js": "/build/app.93b4ef2d.js",
44
"build/runtime.js": "/build/runtime.c217f8c4.js",
55
"build/852.96913092.js": "/build/852.96913092.js",
66
"build/images/VPS-badge.svg": "/build/images/VPS-badge.svg",

src/Controller/EditCounterController.php

Lines changed: 39 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace App\Controller;
66

7+
use App\Helper\AutomatedEditsHelper;
78
use App\Model\EditCounter;
89
use App\Model\GlobalContribs;
910
use App\Model\UserRights;
@@ -92,7 +93,8 @@ public function restrictedApiActions(): array
9293
protected function setUpEditCounter(
9394
EditCounterRepository $editCounterRepo,
9495
UserRightsRepository $userRightsRepo,
95-
RequestStack $requestStack
96+
RequestStack $requestStack,
97+
AutomatedEditsHelper $autoEditsHelper
9698
): void {
9799
// Whether we're making a subrequest (the view makes a request to another action).
98100
// Subrequests to the same controller do not re-instantiate a new controller, and hence
@@ -119,7 +121,8 @@ protected function setUpEditCounter(
119121
$this->i18n,
120122
$this->userRights,
121123
$this->project,
122-
$this->user
124+
$this->user,
125+
$autoEditsHelper
123126
);
124127
}
125128

@@ -242,15 +245,17 @@ private function redirectFromSections(): RedirectResponse
242245
* @param EditCounterRepository $editCounterRepo
243246
* @param UserRightsRepository $userRightsRepo
244247
* @param RequestStack $requestStack
248+
* @param AutomatedEditsHelper $autoEditsHelper
245249
* @return Response|RedirectResponse
246250
* @codeCoverageIgnore
247251
*/
248252
public function resultAction(
249253
EditCounterRepository $editCounterRepo,
250254
UserRightsRepository $userRightsRepo,
251-
RequestStack $requestStack
255+
RequestStack $requestStack,
256+
AutomatedEditsHelper $autoEditsHelper
252257
) {
253-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
258+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
254259

255260
if (1 === count($this->sections)) {
256261
// Redirect to dedicated route.
@@ -297,9 +302,10 @@ public function generalStatsAction(
297302
UserRightsRepository $userRightsRepo,
298303
GlobalContribsRepository $globalContribsRepo,
299304
EditRepository $editRepo,
300-
RequestStack $requestStack
305+
RequestStack $requestStack,
306+
AutomatedEditsHelper $autoEditsHelper
301307
): Response {
302-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
308+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
303309

304310
$globalContribs = new GlobalContribs(
305311
$globalContribsRepo,
@@ -358,9 +364,10 @@ public function generalStatsIndexAction(): Response
358364
public function namespaceTotalsAction(
359365
EditCounterRepository $editCounterRepo,
360366
UserRightsRepository $userRightsRepo,
361-
RequestStack $requestStack
367+
RequestStack $requestStack,
368+
AutomatedEditsHelper $autoEditsHelper
362369
): Response {
363-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
370+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
364371

365372
$ret = [
366373
'xtTitle' => $this->user->getUsername(),
@@ -405,9 +412,10 @@ public function namespaceTotalsIndexAction(): Response
405412
public function timecardAction(
406413
EditCounterRepository $editCounterRepo,
407414
UserRightsRepository $userRightsRepo,
408-
RequestStack $requestStack
415+
RequestStack $requestStack,
416+
AutomatedEditsHelper $autoEditsHelper
409417
): Response {
410-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
418+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
411419

412420
$ret = [
413421
'xtTitle' => $this->user->getUsername(),
@@ -453,9 +461,10 @@ public function timecardIndexAction(): Response
453461
public function yearCountsAction(
454462
EditCounterRepository $editCounterRepo,
455463
UserRightsRepository $userRightsRepo,
456-
RequestStack $requestStack
464+
RequestStack $requestStack,
465+
AutomatedEditsHelper $autoEditsHelper
457466
): Response {
458-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
467+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
459468

460469
$ret = [
461470
'xtTitle' => $this->user->getUsername(),
@@ -500,9 +509,10 @@ public function yearCountsIndexAction(): Response
500509
public function monthCountsAction(
501510
EditCounterRepository $editCounterRepo,
502511
UserRightsRepository $userRightsRepo,
503-
RequestStack $requestStack
512+
RequestStack $requestStack,
513+
AutomatedEditsHelper $autoEditsHelper
504514
): Response {
505-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
515+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
506516

507517
$ret = [
508518
'xtTitle' => $this->user->getUsername(),
@@ -548,9 +558,10 @@ public function monthCountsIndexAction(): Response
548558
public function rightsChangesAction(
549559
EditCounterRepository $editCounterRepo,
550560
UserRightsRepository $userRightsRepo,
551-
RequestStack $requestStack
561+
RequestStack $requestStack,
562+
AutomatedEditsHelper $autoEditsHelper
552563
): Response {
553-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
564+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
554565

555566
$ret = [
556567
'xtTitle' => $this->user->getUsername(),
@@ -628,9 +639,10 @@ public function rightsChangesIndexAction(): Response
628639
public function logCountsApiAction(
629640
EditCounterRepository $editCounterRepo,
630641
UserRightsRepository $userRightsRepo,
631-
RequestStack $requestStack
642+
RequestStack $requestStack,
643+
AutomatedEditsHelper $autoEditsHelper
632644
): JsonResponse {
633-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
645+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
634646

635647
return $this->getFormattedApiResponse([
636648
'log_counts' => $this->editCounter->getLogCounts(),
@@ -674,9 +686,10 @@ public function logCountsApiAction(
674686
public function namespaceTotalsApiAction(
675687
EditCounterRepository $editCounterRepo,
676688
UserRightsRepository $userRightsRepo,
677-
RequestStack $requestStack
689+
RequestStack $requestStack,
690+
AutomatedEditsHelper $autoEditsHelper
678691
): JsonResponse {
679-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
692+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
680693

681694
return $this->getFormattedApiResponse([
682695
'namespace_totals' => (object)$this->editCounter->namespaceTotals(),
@@ -730,9 +743,10 @@ public function namespaceTotalsApiAction(
730743
public function monthCountsApiAction(
731744
EditCounterRepository $editCounterRepo,
732745
UserRightsRepository $userRightsRepo,
733-
RequestStack $requestStack
746+
RequestStack $requestStack,
747+
AutomatedEditsHelper $autoEditsHelper
734748
): JsonResponse {
735-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
749+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
736750

737751
$ret = $this->editCounter->monthCounts();
738752

@@ -790,9 +804,10 @@ public function monthCountsApiAction(
790804
public function timecardApiAction(
791805
EditCounterRepository $editCounterRepo,
792806
UserRightsRepository $userRightsRepo,
793-
RequestStack $requestStack
807+
RequestStack $requestStack,
808+
AutomatedEditsHelper $autoEditsHelper
794809
): JsonResponse {
795-
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack);
810+
$this->setUpEditCounter($editCounterRepo, $userRightsRepo, $requestStack, $autoEditsHelper);
796811

797812
return $this->getFormattedApiResponse([
798813
'timecard' => $this->editCounter->timeCard(),

src/Helper/AutomatedEditsHelper.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,18 @@ public function getTools(Project $project, bool $useSandbox = false): array
187187
return $this->tools[$projectDomain];
188188
}
189189

190+
/**
191+
* Get all the tags associated to automated edits on a given project.
192+
* @param bool $useSandbox Whether to use the /sandbox version for testing (also bypasses caching).
193+
* @return array Array with numeric keys and values being tag names (as in change_tag_def).
194+
*/
195+
public function getTags(Project $project, bool $useSandbox = false): array
196+
{
197+
$tools = $this->getTools($project, $useSandbox);
198+
$tags = array_merge(... array_map(fn($o) => $o["tags"], array_values($tools)));
199+
return $tags;
200+
}
201+
190202
/**
191203
* Merges the given rule sets, giving priority to the local set. Regex is concatenated, not overridden.
192204
* @param string[] $globalRules The global rule set.

0 commit comments

Comments
 (0)