Compare commits

...
Sign in to create a new pull request.

73 commits

Author SHA1 Message Date
0d0
384fdfa2bf Patch ContributionScores for newer tables 2025-01-23 20:21:52 +01:00
libraryupgrader
7f40072416 build: Updating mediawiki/mediawiki-codesniffer to 45.0.0
Change-Id: Ia8f9b33e935bf4f6f2ede29eeabf9acb10c15cb9
2024-11-02 05:55:26 +00:00
libraryupgrader
e00a3b1c57 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 43.0.0 → 44.0.0

npm:
* eslint-config-wikimedia: 0.27.0 → 0.28.2
* braces: 3.0.2 → 3.0.3
  * https://github.com/advisories/GHSA-grv7-fg5c-xmjg
* micromatch: 4.0.5 → 4.0.8
  * https://github.com/advisories/GHSA-952p-6rrq-rcjv

Change-Id: I039053dadabb9bc16cdf7c40cd523745d3e4116f
2024-09-29 02:48:39 +00:00
Umherirrender
95976e0082 Merge "build: Updating grunt-banana-checker to 0.13.0" 2024-09-28 22:24:05 +00:00
ZoruaFox
00af3f2598 Fix wfGetDB deprecated on 1.39 and later versions.
The global function wfGetDB() has been deprecated since 1.39,
use LoadBalancer::getConnection() instead of old function.

Bug: T369145
Change-Id: Ided5ed8d1e54428541f067c75fbe7fdfeefc460f
2024-07-03 22:17:33 +00:00
libraryupgrader
2b415b36b5 build: Updating grunt-banana-checker to 0.13.0
Change-Id: Ibbdc718ea757b24ed4585f5f6e8a77bbb4f5f24f
2024-05-18 05:11:57 +00:00
libraryupgrader
1cf9ae8247 build: Updating dependencies
composer:
* mediawiki/minus-x: 1.1.1 → 1.1.3

npm:
* grunt-banana-checker: 0.11.1 → 0.12.0

Change-Id: I7c6aa5e4e1c0c2c7c6410a0745febb443eceebe7
2024-05-10 03:07:37 +00:00
libraryupgrader
548a1f177c build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 41.0.0 → 43.0.0
* php-parallel-lint/php-parallel-lint: 1.3.2 → 1.4.0

npm:
* eslint-config-wikimedia: 0.25.0 → 0.27.0
* grunt-banana-checker: 0.10.0 → 0.11.1
* grunt-eslint: 24.0.1 → 24.3.0

Change-Id: Iee9ef20b4984ad7459d77cc77c59394667954370
2024-04-22 02:10:29 +00:00
Umherirrender
645c945994 Merge "Fix "Cannot access non-public property Parser::$mStripState"" 2023-09-03 18:06:37 +00:00
Luca Mauri
4212d24b49 Fix "Cannot access non-public property Parser::$mStripState"
Discussed under https://www.mediawiki.org/wiki/Topic:Xc6c9apmxydt7817

Bug: T333675
Change-Id: Ifd38878edfd6481de85efd716e4f954cd1e449bb
2023-09-03 18:04:04 +00:00
libraryupgrader
7d145662fa build: Updating npm dependencies
* eslint-config-wikimedia: 0.24.0 → 0.25.0
* grunt-eslint: 24.0.0 → 24.0.1

Change-Id: I3a7cc1836a78f282f900b3405a9e7215803d6e38
2023-05-04 01:44:08 +00:00
libraryupgrader
7cc5575eaa build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 40.0.1 → 41.0.0

npm:
* eslint-config-wikimedia: 0.22.1 → 0.24.0
* grunt: 1.5.3 → 1.6.1

Change-Id: Ic11909141e1d3be2b5100878ff7bcec5acdf48e9
2023-03-15 04:15:54 +00:00
libraryupgrader
945f54a773 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 39.0.0 → 40.0.1

npm:
* grunt-banana-checker: 0.9.0 → 0.10.0
* minimatch: 3.0.4 → 3.0.8
  * https://github.com/advisories/GHSA-f8q6-p94x-37v3

Change-Id: I55d1c7498aea0581127daa4c09cf44f846f34f7e
2022-12-30 01:11:43 +00:00
Vedmaka
d4dae78b27 Make $wgContribScoreCacheTTL affect caching of embedded Special:ContributionScores page
Change-Id: I526362c422f611e3f8882be5575618f530b868b2
2022-12-11 10:43:17 +00:00
libraryupgrader
e307850555 build: Updating grunt to 1.5.3
Change-Id: I0fe9a27b6b821d9960553f487cd9bcf30ebd7a5b
2022-05-26 09:21:33 +00:00
libraryupgrader
790e23f9bb build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 38.0.0 → 39.0.0
* php-parallel-lint/php-console-highlighter: 0.5.0 → 1.0.0
* php-parallel-lint/php-parallel-lint: 1.3.1 → 1.3.2

npm:
* grunt-eslint: 23.0.0 → 24.0.0

Change-Id: I426c1f103cbfce83d09ceefc71eb87c3691818eb
2022-05-21 02:08:18 +00:00
libraryupgrader
7fa71f5e78 build: Updating grunt to 1.5.2
Change-Id: I58cfa3b96a1c508aef987523df9bb2985dc0c6c0
2022-04-27 09:04:20 +00:00
libraryupgrader
6666f47f3b build: Updating npm dependencies
* eslint-config-wikimedia: 0.21.0 → 0.22.1
* async: 3.2.0 → 3.2.3
  * https://github.com/advisories/GHSA-fwr7-v2mv-hh25

Change-Id: I10969887274d014e0273eda8828ec1c6b7b3f9af
2022-04-15 01:45:18 +00:00
libraryupgrader
46ebf43828 build: Updating npm dependencies
* eslint-config-wikimedia: 0.20.0 → 0.21.0
* grunt: 1.4.0 → 1.4.1

Additional changes:
* Set `name` in package.json.

Change-Id: I2bccb381a68affd8a8fe33f6b3948c75e72d1be5
2022-02-06 08:43:55 +00:00
Umherirrender
c68abe1641 Replace deprecated IDatabase::fetchObject
Bug: T286694
Change-Id: I78ae801c9fec3de0495f355b90edaac703faa169
2022-02-04 23:16:47 +01:00
Umherirrender
f9aa4a74b3 Remove PHP entry point
Change-Id: I1d6b3a1f2078b0e2db844d1334dcafc3794c9f74
2021-12-04 16:22:55 +01:00
libraryupgrader
d4132dab01 build: Updating mediawiki/mediawiki-codesniffer to 38.0.0
Change-Id: I71c9a24b73892aae722bda6a50ecfe9a735a377c
2021-10-24 01:34:43 +00:00
jenkins-bot
228317e7c6 Merge "Use MainWANObjectCache to improve performance" 2021-10-13 12:51:46 +00:00
Translation updater bot
c1d095e381 Localisation updates from https://translatewiki.net.
Change-Id: I8ab537624f7ddbd1af32a8acd3c4781686b23663
2021-10-07 09:02:42 +02:00
jenkins-bot
120ae2bac0 Use MainWANObjectCache to improve performance
Bug: T278030
Change-Id: I7e8487ff9b2e7c9038bd058aa11cd844450b165a
2021-10-06 04:50:00 +00:00
jenkins-bot
fb464fbd13 Merge "Adds configuration directive to filter specified usernames from the contribution scores tables." 2021-10-05 14:38:02 +00:00
libraryupgrader
6a8d6116e1 build: Updating dependencies
composer:
* php-parallel-lint/php-parallel-lint: 1.3.0 → 1.3.1

npm:
* ansi-regex: 5.0.0 → 5.0.1
  * https://npmjs.com/advisories/5197 (CVE-2021-3807)

Additional changes:
* composer.json: Updated phpcs command in composer test (T280592).
* composer.json: Added phpcs command to scripts (T280592).

Change-Id: Id67c2545f7d06ca94a8ca68c3196534cfaf1addc
2021-10-04 15:47:44 +00:00
Chris Rishel
35ea80cb36 Adds configuration directive to filter specified usernames from the contribution scores tables.
Bug: T292266
Change-Id: I641fbd3d8b088132cba4f142ee99a8837a02afb3
2021-10-04 08:17:14 +00:00
jenkins-bot
b7bf249857 Merge "Introduce a config, to use the rough number of edits in user table" 2021-09-28 08:43:42 +00:00
libraryupgrader
0a533b36f5 build: Updating path-parse to 1.0.7
* https://npmjs.com/advisories/1773 (CVE-2021-23343)

Change-Id: I6470d91980875027c16f172ca7d8bc4806c30c7b
2021-08-11 16:34:14 +00:00
Translation updater bot
5be2c8ed72 Localisation updates from https://translatewiki.net.
Change-Id: I10e4d8f6ee64b19de0da79a06e9e432cab34ab58
2021-07-26 08:12:02 +02:00
libraryupgrader
71ace6a83c build: Updating mediawiki/mediawiki-codesniffer to 37.0.0
Change-Id: I6c7f39e6c29ddee30e5f5885e92564f212068431
2021-07-22 15:28:36 +00:00
Func
6024bfd83b Introduce a config, to use the rough number of edits in user table
Bug: T278030
Change-Id: Ibd6d0380cc091e4720fb038bd8c663a6ebb4a6ea
2021-07-01 08:34:58 +00:00
jenkins-bot
5ade4bf529 Merge "Minor cleanups on ContributionScores extension" 2021-06-22 07:48:23 +00:00
Translation updater bot
81fe64aea5 Localisation updates from https://translatewiki.net.
Change-Id: I930be97a774bd7933400a25625db751bcad862fc
2021-05-27 12:05:05 +02:00
libraryupgrader
32d5ef59fa build: Updating browserslist to 4.16.6
* https://npmjs.com/advisories/1747 (CVE-2021-23364)

Change-Id: I6e74e9f54e2d24910830797007e035d39b96f58d
2021-05-25 09:43:35 +00:00
Func
b0e2a7c59a Minor cleanups on ContributionScores extension
Change-Id: If35b44623ce27fa80c44f6bd18ceffdf9d9811b9
2021-05-15 14:31:22 +00:00
jenkins-bot
89e7ebc584 Merge "Use User->isRegistered(), not deprecated isLoggedIn()" 2021-05-11 14:08:12 +00:00
libraryupgrader
908d2f68a2 build: Updating grunt to 1.4.0
Change-Id: Ic8eb79e109e0d82ff0e335cb55176fefe2183c0b
2021-05-09 10:24:41 +00:00
libraryupgrader
95800b51f3 build: Updating lodash to 4.17.21
* https://npmjs.com/advisories/1673 (CVE-2021-23337)

Change-Id: I5aafa6c6e11e2e47f1e3fe6ab089aa8416711632
2021-05-07 18:43:26 +00:00
ZabeMath
bb3429ecff Use User->isRegistered(), not deprecated isLoggedIn()
Bug: T270450
Change-Id: I1018c6a76af5685026d956f5c010b5537cf3011e
2021-05-06 17:57:17 +02:00
libraryupgrader
e5d96719d8 build: Updating composer dependencies
* mediawiki/mediawiki-codesniffer: 35.0.0 → 36.0.0
* php-parallel-lint/php-parallel-lint: 1.2.0 → 1.3.0

Change-Id: I99b71bd05c86f67e2af45f8b055c956b9515c831
2021-05-04 02:52:03 +00:00
Translation updater bot
fcb9c19544 Localisation updates from https://translatewiki.net.
Change-Id: Ib231bfa7ce8c0d1d639e38bf2eec872031eb518a
2021-05-03 08:36:37 +02:00
jenkins-bot
20f33b07f3 Merge "Query for array of join with ActorMigration::getJoin() to improve performance" 2021-04-21 11:48:18 +00:00
libraryupgrader
309914b267 build: Updating eslint-config-wikimedia to 0.20.0
Change-Id: Iaa507a243cfe7bde4987bd77239a9391faf9e76d
2021-04-16 07:15:21 +00:00
Func
571a707b3b Query for array of join with ActorMigration::getJoin() to improve performance
There is no need for comment text, RevisionStore::getQueryInfo() is overkill, and will cause more time in database query.

Bug: T278030
Change-Id: I9c062cd66677aa7d473a3283f29b0e39c5b4ea02
2021-04-02 15:40:27 +00:00
Translation updater bot
20b9a568e2 Localisation updates from https://translatewiki.net.
Change-Id: I80772b10562895d7f7f1b8ae0ad76df8585f53ab
2021-04-01 08:37:06 +02:00
Func
4dc3f4fc3e Update ContributionScores for expiring user groups
Bug: T160020
Change-Id: I66c9108133d2bdd5dc29336a525480764c95f5c2
2021-03-14 03:32:57 +00:00
libraryupgrader
6fac0091ec build: Updating eslint-config-wikimedia to 0.19.0
Additional changes:
* eslint: Renamed `wikimedia/client` profile to `client-es5` (T277085).

Change-Id: Ia3589bc2b6f071b3bbb41a11efb11f1456a521ca
2021-03-13 08:51:18 +00:00
libraryupgrader
0c3861304e build: Updating eslint-config-wikimedia to 0.18.2
Change-Id: I1d38f31a482edce1a357d36a6ab1479282402c80
2021-03-06 11:23:51 +00:00
Func
9f53a1eba9 Set descriptionmsg in extension.json correctly
Change-Id: Ie4eb287a6fc7f9461aab1267b44c6240fd23a28f
2021-02-19 15:01:39 +00:00
Translation updater bot
2dc00fa1ae Localisation updates from https://translatewiki.net.
Change-Id: I54a8b2e66f8ccfeb0029ba16f3148d07fad852c4
2021-02-16 08:29:47 +01:00
zoranzoki21
ca10b2089e Add alias for Serbian language
Change-Id: I13aeed4f0ff277238fe1fbd9164d850bbf4247d1
2021-02-06 15:02:53 +00:00
zoranzoki21
fdcc307d8e extension.json: Bump version number
Change-Id: Ie3963a209b494c3a9e82d39cd76ce399fb181685
2021-02-06 15:53:22 +01:00
zoranzoki21
9d46bcf5c7 Fix few PHPCS excludes
Change-Id: I999ff9d6ffbc727d74221a62080895af21495772
2021-02-06 15:52:52 +01:00
func
b8a91c6731 Convert ContributionScores to use extension registration
Bug: T174046
Change-Id: I293050ddc01699420b7dad884b51f5241e46137f
2021-02-06 11:53:15 +08:00
libraryupgrader
e51c7662d1 build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 34.0.0 → 35.0.0
* mediawiki/minus-x: 1.1.0 → 1.1.1

npm:
* eslint-config-wikimedia: 0.17.0 → 0.18.1

Additional changes:
* Removing manual extensions for eslint.

Change-Id: I986ee614ae25668d33c1aa3c5cb790352fb24c89
2021-01-29 07:46:25 +00:00
Translation updater bot
18e42f349b Localisation updates from https://translatewiki.net.
Change-Id: I956883f08b25f3c7dfe80048da032f690c4f0377
2020-12-15 08:35:32 +01:00
libraryupgrader
ddd94477cf build: Updating ini to 1.3.8
* https://npmjs.com/advisories/1589

Change-Id: Ia0b4818083308050beb40b354d3e33ad0bb65db7
2020-12-13 00:07:38 +00:00
Translation updater bot
95f9a48ac4 Localisation updates from https://translatewiki.net.
Change-Id: Ibabecd30ad0076609b25c2614cdd6125e6cf6ced
2020-12-07 08:44:05 +01:00
libraryupgrader
5aefac796c build: Updating mediawiki/mediawiki-codesniffer to 34.0.0
Change-Id: I0364be0450fc92a35f3623626bde7697a28b4e7c
2020-12-06 05:02:37 +00:00
Translation updater bot
4f60431795 Localisation updates from https://translatewiki.net.
Change-Id: I4d13bf09a01197c17748f7d14c906507f756690d
2020-11-26 08:27:45 +01:00
Translation updater bot
b11635777b Localisation updates from https://translatewiki.net.
Change-Id: I9b8672b1268df7d805fa1fe7a241146860a41920
2020-11-11 08:35:29 +01:00
libraryupgrader
f42092ec06 build: Updating mediawiki/mediawiki-codesniffer to 33.0.0
Change-Id: Id2c3212e2edfcdede0e1033a490905d6c361e1b4
2020-11-03 15:49:32 +00:00
libraryupgrader
a131b2a47b build: Updating mediawiki/mediawiki-codesniffer to 32.0.0
The following sniffs are failing and were disabled:
* MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage

Additional changes:
* Dropped .php5 and .inc files from .phpcs.xml (T200956).
* Added the `wikimedia/mediawiki` profile in .eslintrc.json (T262222).
* Removed global `mw`, included via `wikimedia/mediawiki` profile (T262222).
* Dropped the emtpy global definition in .eslintrc.json.

Change-Id: I9a87a358cb5336c9d18261985209c1f845337160
2020-10-29 09:17:32 +00:00
Translation updater bot
6e2d039150 Localisation updates from https://translatewiki.net.
Change-Id: Ie53409ab2fa33061eaac2cf4cbd79b619536cce9
2020-09-14 09:13:45 +02:00
libraryupgrader
b04514e353 build: Updating npm dependencies
* eslint-config-wikimedia: 0.16.2 → 0.17.0
* grunt: 1.2.1 → 1.3.0

Change-Id: I2d78f6a806ee8c6aa94fbc89acbc863c4ee23898
2020-09-05 11:59:09 +00:00
Translation updater bot
de739003d4 Localisation updates from https://translatewiki.net.
Change-Id: Id4a38aede91bd646e162c359d7af61defabfa181
2020-08-05 08:22:19 +02:00
Translation updater bot
ea143f6b66 Localisation updates from https://translatewiki.net.
Change-Id: Ia7c25a6b6eb41cab772f5699c75f212a5c972040
2020-07-27 08:37:06 +02:00
Translation updater bot
70cc5ee193 Localisation updates from https://translatewiki.net.
Change-Id: I8d8fdb23f485b4ae669084aa7b8944fb49862698
2020-07-24 08:26:32 +02:00
Translation updater bot
234c4f6622 Localisation updates from https://translatewiki.net.
Change-Id: I961864c32baff11ea4b48df546a5f6cddc3aef32
2020-07-21 09:11:04 +02:00
libraryupgrader
2b3ff2324d build: Updating grunt to 1.2.1
Change-Id: Ie5a886a5fea63f73d443b3a53ec8c184e56d8c22
2020-07-18 04:04:11 +00:00
libraryupgrader
4817b0112c build: Updating npm dependencies
* eslint-config-wikimedia: 0.15.3 → 0.16.2
* grunt-eslint: 22.0.0 → 23.0.0

Change-Id: I5a46ab233ea39978e523b4706bffa347e347f8ab
2020-07-16 20:53:15 +00:00
25 changed files with 5838 additions and 1161 deletions

View file

@ -1,10 +1,8 @@
{
"root": true,
"extends": [
"wikimedia/client",
"wikimedia/jquery"
],
"globals": {
"mw": false
}
"wikimedia/client-es5",
"wikimedia/jquery",
"wikimedia/mediawiki"
]
}

View file

@ -1,12 +1,12 @@
<?xml version="1.0"?>
<ruleset>
<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<exclude name="MediaWiki.Files.ClassMatchesFilename.NotMatch" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationProtected" />
<exclude name="MediaWiki.Commenting.FunctionComment.MissingDocumentationPublic" />
<exclude name="MediaWiki.Usage.ExtendClassUsage.FunctionConfigUsage" />
<exclude name="PSR12.Properties.ConstantVisibility.NotFound" />
<exclude name="Squiz.Scope.MethodScope.Missing" />
</rule>
<file>.</file>
<arg name="extensions" value="php,php5,inc" />
<arg name="extensions" value="php" />
<arg name="encoding" value="UTF-8" />
</ruleset>

View file

@ -233,6 +233,16 @@ $specialPageAliases['sk'] = [
'ContributionScores' => [ 'SkórePríspevkov' ],
];
/** Serbian Cyrillic (српски (ћирилица)) */
$specialPageAliases['sr-ec'] = [
'ContributionScores' => [ 'ОценеДоприноса' ],
];
/** Serbian Latin (srpski (latinica)) */
$specialPageAliases['sr-el'] = [
'ContributionScores' => [ 'OceneDoprinosa' ],
];
/** Swedish (svenska) */
$specialPageAliases['sv'] = [
'ContributionScores' => [ 'Bidragspoäng' ],

View file

@ -1,109 +0,0 @@
<?php
/** \file
* \brief Contains setup code for the Contribution Scores Extension.
*/
# Not a valid entry point, skip unless MEDIAWIKI is defined
if ( !defined( 'MEDIAWIKI' ) ) {
echo 'Contribution Scores extension';
exit( 1 );
}
$wgExtensionCredits['specialpage'][] = [
'path' => __FILE__,
'name' => 'Contribution Scores',
'url' => 'https://www.mediawiki.org/wiki/Extension:Contribution_Scores',
'author' => 'Tim Laqua',
'descriptionmsg' => 'contributionscores-desc',
'version' => '1.25.0'
];
define( 'CONTRIBUTIONSCORES_MAXINCLUDELIMIT', 50 );
$wgContribScoreReports = null;
// These settings can be overridden in LocalSettings.php.
// Set to true to exclude bots from the reporting.
$wgContribScoreIgnoreBlockedUsers = false;
// Set to true to exclude blocked users from the reporting.
$wgContribScoreIgnoreBots = false;
// Set to true to use real user names when available. Only for MediaWiki 1.19 and later.
$wgContribScoresUseRealName = false;
// Set to true to disable cache for parser function and inclusion of table.
$wgContribScoreDisableCache = false;
$wgAutoloadClasses['ContributionScores'] = __DIR__ . '/ContributionScores_body.php';
$wgSpecialPages['ContributionScores'] = 'ContributionScores';
$wgMessagesDirs['ContributionScores'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['ContributionScoresAlias'] = __DIR__ . '/ContributionScores.alias.php';
$wgExtensionMessagesFiles['ContributionScoresMagic'] =
__DIR__ . '/ContributionScores.i18n.magic.php';
$wgHooks['ParserFirstCallInit'][] = 'efContributionScores_Setup';
function efContributionScores_Setup( &$parser ) {
$parser->setFunctionHook( 'cscore', 'efContributionScores_Render' );
return true;
}
function efContributionScores_Render( &$parser, $usertext, $metric = 'score' ) {
global $wgContribScoreDisableCache;
if ( $wgContribScoreDisableCache ) {
$parser->getOutput()->updateCacheExpiry( 0 );
}
$user = User::newFromName( $usertext );
$dbr = wfGetDB( DB_REPLICA );
if ( $user instanceof User && $user->isLoggedIn() ) {
global $wgLang;
$revWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $user );
if ( $metric == 'score' ) {
$res = $dbr->select(
[ 'revision' ] + $revWhere['tables'],
'COUNT(DISTINCT rev_page)+SQRT(COUNT(rev_id)-COUNT(DISTINCT rev_page))*2 AS wiki_rank',
$revWhere['conds'],
__METHOD__,
[],
$revWhere['joins']
);
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
} elseif ( $metric == 'changes' ) {
$res = $dbr->select(
[ 'revision' ] + $revWhere['tables'],
'COUNT(rev_id) AS rev_count',
$revWhere['conds'],
__METHOD__,
[],
$revWhere['joins']
);
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->rev_count );
} elseif ( $metric == 'pages' ) {
$res = $dbr->select(
[ 'revision' ] + $revWhere['tables'],
'COUNT(DISTINCT rev_page) AS page_count',
$revWhere['conds'],
__METHOD__,
[],
$revWhere['joins']
);
$row = $dbr->fetchObject( $res );
$output = $wgLang->formatNum( $row->page_count );
} else {
$output = wfMessage( 'contributionscores-invalidmetric' )->text();
}
} else {
$output = wfMessage( 'contributionscores-invalidusername' )->text();
}
return $parser->insertStripItem( $output, $parser->mStripState );
}

View file

@ -11,7 +11,6 @@ module.exports = function ( grunt ) {
},
eslint: {
options: {
extensions: [ '.js', '.json' ],
cache: true
},
all: [

View file

@ -1,9 +1,9 @@
{
"require-dev": {
"mediawiki/mediawiki-codesniffer": "31.0.0",
"mediawiki/minus-x": "1.1.0",
"php-parallel-lint/php-console-highlighter": "0.5.0",
"php-parallel-lint/php-parallel-lint": "1.2.0"
"mediawiki/mediawiki-codesniffer": "45.0.0",
"mediawiki/minus-x": "1.1.3",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"php-parallel-lint/php-parallel-lint": "1.4.0"
},
"scripts": {
"fix": [
@ -12,8 +12,14 @@
],
"test": [
"parallel-lint . --exclude vendor --exclude node_modules",
"phpcs -p -s",
"@phpcs",
"minus-x check ."
]
],
"phpcs": "phpcs -sp --cache"
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

64
extension.json Normal file
View file

@ -0,0 +1,64 @@
{
"name": "ContributionScores",
"author": "Tim Laqua",
"url": "https://www.mediawiki.org/wiki/Extension:Contribution_Scores",
"descriptionmsg": "contributionscores-desc",
"version": "1.26.1",
"type": "specialpage",
"requires": {
"MediaWiki": ">= 1.34.0"
},
"SpecialPages": {
"ContributionScores": "ContributionScores"
},
"AutoloadClasses": {
"ContributionScores": "src/ContributionScores.php"
},
"Hooks": {
"ParserFirstCallInit": "ContributionScores::onParserFirstCallInit"
},
"MessagesDirs": {
"ContributionScores": [
"i18n"
]
},
"ExtensionMessagesFiles": {
"ContribScoreAlias": "ContributionScores.alias.php",
"ContribScoreMagic": "ContributionScores.i18n.magic.php"
},
"config": {
"ContribScoreReports": {
"value": null,
"description": "Each array defines a report - 7,50 is \"past 7 days \" and \"LIMIT 50 \" - Can be omitted."
},
"ContribScoreIgnoreBlockedUsers": {
"value": false,
"description": "Set to true to exclude blocked users from the reporting."
},
"ContribScoreIgnoreBots": {
"value": false,
"description": "Set to true to exclude bots users from the reporting."
},
"ContribScoreIgnoreUsernames": {
"value": [],
"description": "Array of usernames to exclude from the reporting."
},
"ContribScoresUseRealName": {
"value": false,
"description": "Set to true to use real user names when available."
},
"ContribScoreDisableCache": {
"value": false,
"description": "Set to true to disable cache for parser function and inclusion of table."
},
"ContribScoreUseRoughEditCount": {
"value": false,
"description": "Set to true to use the rough number of edits in user table, for performance issue."
},
"ContribScoreCacheTTL": {
"value": 30,
"description": "Cache the contribution scores data, in minutes."
}
},
"manifest_version": 2
}

View file

@ -3,7 +3,8 @@
"authors": [
"CERminator",
"KWiki",
"Srdjan m"
"Srdjan m",
"Srđan"
]
},
"contributionscores": "Rezultat doprinosa",

View file

@ -4,7 +4,8 @@
"Byrial",
"Christian List",
"Kaare",
"Peter Alberti"
"Peter Alberti",
"Saederup92"
]
},
"contributionscores": "Bidragspoint",
@ -14,6 +15,7 @@
"contributionscores-days": "Sidste {{PLURAL:$1|dag|$1 dage}}",
"contributionscores-allrevisions": "Gennem tiden",
"contributionscores-score": "Point",
"contributionscores-rank": "Rang",
"contributionscores-pages": "Sider",
"contributionscores-changes": "Ændringer",
"contributionscores-username": "Brugernavn",

View file

@ -11,7 +11,7 @@
"contributionscores-info": "Ebe pawıtışê hecmê tedqiqê berzi ra, puwan raveri pelanê bêemsalanê vurniyayeyan senceno.",
"contributionscores-top": "(Tewr Gırde $1)",
"contributionscores-days": "{{PLURAL:$1|Roca peyêne|$1 Rocê peyêni}}",
"contributionscores-allrevisions": "Çaxan de hemi",
"contributionscores-allrevisions": "Her dem",
"contributionscores-score": "Puwan",
"contributionscores-rank": "Rêze",
"contributionscores-pages": "Peli",

View file

@ -15,4 +15,4 @@
"contributionscores-username": "Username",
"contributionscores-invalidusername": "Invalid username",
"contributionscores-invalidmetric": "Invalid metric"
}
}

View file

@ -1,8 +0,0 @@
{
"@metadata": {
"authors": [
"Better"
]
},
"contributionscores-days": "Úrtimus $1 dias"
}

View file

@ -1,6 +1,7 @@
{
"@metadata": {
"authors": [
"01miki10",
"Crt",
"Nike",
"Pxos",
@ -18,7 +19,7 @@
"contributionscores-rank": "Sija",
"contributionscores-pages": "Sivuja",
"contributionscores-changes": "Muutoksia",
"contributionscores-username": "Käyttäjätunnus",
"contributionscores-invalidusername": "Virheellinen käyttäjätunnus",
"contributionscores-username": "Käyttäjänimi",
"contributionscores-invalidusername": "Virheellinen käyttäjänimi",
"contributionscores-invalidmetric": "Virheellinen muuttuja"
}

View file

@ -21,6 +21,6 @@
"contributionscores-pages": "Pages",
"contributionscores-changes": "Changements",
"contributionscores-username": "Nom dutilisateur",
"contributionscores-invalidusername": "Nom dutilisateur invalide",
"contributionscores-invalidusername": "Nom dutilisateur incorrect",
"contributionscores-invalidmetric": "Métrique incorrecte"
}

View file

@ -6,11 +6,12 @@
},
"contributionscores": "Contes de contribution",
"contributionscores-desc": "Calcula li funde de data del wiki por max alt [[Special:ContributionScores|volúmine de contribution de usator]]",
"contributionscores-info": "Contes es calculat quam seque:\n*Un (1) punctu por chascun págine unic redactet\n*Fonte de quadrat de (total de redactiones fat) - (total unique pages) * 2\nContes calculat in ti diversitá de redaction in pesa maniere súper de volúmine de redaction.\nBasicmen, ti conte mesura primarimen págines unic redactet, che consideration por alt volúmine de redaction - suposit esser un págine de alt qualitá.",
"contributionscores-info": "Li calcul primarimen mesura págines unic redactet, considerant li alt volume de redactiones.",
"contributionscores-top": "(Prim $1)",
"contributionscores-days": "Ultim {{PLURAL:$1|die|$1 dies}}",
"contributionscores-allrevisions": "Omni témpor",
"contributionscores-score": "Conte",
"contributionscores-rank": "Classification",
"contributionscores-pages": "Págines",
"contributionscores-changes": "Changes",
"contributionscores-username": "Nómine de usator",

View file

@ -5,6 +5,8 @@
]
},
"contributionscores-days": "Lasta {{PLURAL:$1|dio|$1 dii}}",
"contributionscores-score": "Nombro di punti",
"contributionscores-pages": "Pagini",
"contributionscores-changes": "Modifikuri",
"contributionscores-username": "Uzeronomo"
}

View file

@ -1,10 +1,12 @@
{
"@metadata": {
"authors": [
"Balyozxane",
"George Animal"
]
},
"contributionscores-allrevisions": "Hemû dem",
"contributionscores-pages": "Rûpel",
"contributionscores-changes": "Guhartin",
"contributionscores-username": "Navê bikarhêner"
}

View file

@ -1,9 +1,11 @@
{
"@metadata": {
"authors": [
"Abbas dhothar",
"BukhariSaeed"
]
},
"contributionscores-days": "پچھلے{{PLURAL:$1|دن|$1 دناں}}",
"contributionscores-changes": "تبدیلیاں",
"contributionscores-username": "ورتن آلے دا ناں"
}

View file

@ -3,16 +3,18 @@
"authors": [
"Helix84",
"Luky001",
"Teslaton"
"Teslaton",
"Yardom78"
]
},
"contributionscores": "Skóre príspevkov",
"contributionscores-desc": "Zisťuje naväčší [[Special:ContributionScores|objem používateľských príspevkov]] z databázy wiki",
"contributionscores-desc": "Získava údaje z databázy wiki o [[Special:ContributionScores|množstve používateľských príspevkov]]",
"contributionscores-info": "Skóre primárne meria jedinečné editované stránky s ohľadom na veľké množstvo úprav.",
"contributionscores-top": "(Najlepších $1)",
"contributionscores-days": "{{PLURAL:$1|Posledný $1 deň|Posledné $1 dni|Posledných $1 dní}}",
"contributionscores-allrevisions": "Celá história",
"contributionscores-allrevisions": "Celkom",
"contributionscores-score": "Skóre",
"contributionscores-rank": "Poradie",
"contributionscores-pages": "Stránky",
"contributionscores-changes": "Zmeny",
"contributionscores-username": "Používateľské meno",

View file

@ -2,6 +2,7 @@
"@metadata": {
"authors": [
"Acamicamacaraca",
"Kizule",
"Milicevic01",
"Rancher",
"Sasa Stefanovic",

View file

@ -6,5 +6,5 @@
},
"contributionscores-pages": "ገጻት",
"contributionscores-changes": "ለውጥታት",
"contributionscores-username": "ም ተጠቃሚ"
"contributionscores-username": "ም ተጠቃሚ"
}

View file

@ -1,7 +1,9 @@
{
"@metadata": {
"authors": [
"Moon0319",
"PhiLiP",
"Roy17",
"Shinjiman",
"Shirayuki",
"Yueman"
@ -12,7 +14,7 @@
"contributionscores-info": "呢個分數係會依主要嘅唯一編輯過嘅頁,同埋考慮高編輯量。",
"contributionscores-top": "(最高$1名)",
"contributionscores-days": "最近$1日",
"contributionscores-allrevisions": "全部時間",
"contributionscores-allrevisions": "有史以來",
"contributionscores-score": "分數",
"contributionscores-rank": "等級",
"contributionscores-pages": "版",

6518
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,12 +1,13 @@
{
"name": "ContributionScores",
"private": true,
"scripts": {
"test": "grunt test"
},
"devDependencies": {
"eslint-config-wikimedia": "0.15.3",
"grunt": "1.1.0",
"grunt-banana-checker": "0.9.0",
"grunt-eslint": "22.0.0"
"eslint-config-wikimedia": "0.28.2",
"grunt": "1.6.1",
"grunt-banana-checker": "0.13.0",
"grunt-eslint": "24.3.0"
}
}

View file

@ -15,71 +15,155 @@ use MediaWiki\MediaWikiServices;
* @author Tim Laqua <t.laqua@gmail.com>
*/
class ContributionScores extends IncludableSpecialPage {
const CONTRIBUTIONSCORES_MAXINCLUDELIMIT = 50;
public function __construct() {
parent::__construct( 'ContributionScores' );
}
/// Generates a "Contribution Scores" table for a given LIMIT and date range
public static function onParserFirstCallInit( Parser $parser ) {
$parser->setFunctionHook( 'cscore', [ self::class, 'efContributionScoresRender' ] );
}
public static function efContributionScoresRender( $parser, $usertext, $metric = 'score' ) {
global $wgContribScoreDisableCache, $wgContribScoreUseRoughEditCount;
if ( $wgContribScoreDisableCache ) {
$parser->getOutput()->updateCacheExpiry( 0 );
}
$user = User::newFromName( $usertext );
$loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
$dbr = $loadBalancer->getConnection( DB_REPLICA );
if ( $user instanceof User && $user->isRegistered() ) {
global $wgLang;
$revVar = $wgContribScoreUseRoughEditCount ? 'user_editcount' : 'COUNT(rev_id)';
$revWhere = ActorMigration::newMigration()->getWhere( $dbr, 'rev_user', $user );
if ( $metric == 'score' ) {
$row = $dbr->selectRow(
[ 'revision' ] + $revWhere['tables'],
[ 'wiki_rank' => "COUNT(DISTINCT rev_page)+SQRT($revVar-COUNT(DISTINCT rev_page))*2" ],
$revWhere['conds'],
__METHOD__,
[],
$revWhere['joins']
);
$output = $wgLang->formatNum( round( $row->wiki_rank, 0 ) );
} elseif ( $metric == 'changes' ) {
$row = $dbr->selectRow(
[ 'revision' ] + $revWhere['tables'],
[ 'rev_count' => $revVar ],
$revWhere['conds'],
__METHOD__,
[],
$revWhere['joins']
);
$output = $wgLang->formatNum( $row->rev_count );
} elseif ( $metric == 'pages' ) {
$row = $dbr->selectRow(
[ 'revision' ] + $revWhere['tables'],
[ 'page_count' => 'COUNT(DISTINCT rev_page)' ],
$revWhere['conds'],
__METHOD__,
[],
$revWhere['joins']
);
$output = $wgLang->formatNum( $row->page_count );
} else {
$output = wfMessage( 'contributionscores-invalidmetric' )->text();
}
} else {
$output = wfMessage( 'contributionscores-invalidusername' )->text();
}
return $parser->insertStripItem( $output, $parser->getStripState() );
}
/**
* Function generates Contribution Scores tables in HTML format (not wikiText)
* Function fetch Contribution Scores data from database
*
* @param int $days Days in the past to run report for
* @param int $limit Maximum number of users to return (default 50)
* @param string|null $title The title of the table
* @param array $options array of options (default none; nosort/notools)
* @return string Html Table representing the requested Contribution Scores.
* @return array Data including the requested Contribution Scores.
*/
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoresUseRealName;
public static function getContributionScoreData( $days, $limit ) {
global $wgContribScoreIgnoreBots, $wgContribScoreIgnoreBlockedUsers, $wgContribScoreIgnoreUsernames,
$wgContribScoreUseRoughEditCount;
$opts = explode( ',', strtolower( $options ) );
$loadBalancer = MediaWikiServices::getInstance()->getDBLoadBalancer();
$dbr = $loadBalancer->getConnection( DB_REPLICA );
$dbr = wfGetDB( DB_REPLICA );
$store = MediaWikiServices::getInstance()
->getRevisionStoreFactory()
->getRevisionStore();
$revQuery = $store->getQueryInfo();
$revQuery = ActorMigration::newMigration()->getJoin( 'rev_user' );
$revQuery['tables'] = array_merge( [ 'revision' ], $revQuery['tables'] );
$revUser = $revQuery['fields']['rev_user'];
$revUsername = $revQuery['fields']['rev_user_text'];
$sqlWhere = [];
if ( $days > 0 ) {
$date = time() - ( 60 * 60 * 24 * $days );
$dateString = $dbr->timestamp( $date );
$sqlWhere[] = "rev_timestamp > '$dateString'";
$sqlWhere[] = 'rev_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( $date ) );
}
$sqlVars = [
'rev_user' => $revUser,
'page_count' => 'COUNT(DISTINCT rev_page)'
];
if ( $wgContribScoreUseRoughEditCount ) {
$revQuery['tables'][] = 'user';
$revQuery['joins']['user'] = [ 'LEFT JOIN', [ "$revUser != 0", "user_id = $revUser" ] ];
$sqlVars['rev_count'] = 'user_editcount';
} else {
$sqlVars['rev_count'] = 'COUNT(rev_id)';
}
if ( $wgContribScoreIgnoreBlockedUsers ) {
$sqlWhere[] = "{$revUser} NOT IN " .
$dbr->buildSelectSubquery( 'ipblocks', 'ipb_user', 'ipb_user <> 0', __METHOD__ );
$dbr->buildSelectSubquery( [
'block',
'block_target'
],
'bt_user',
'bt_user <> 0',
__METHOD__,
[],
[
'block_target' => [ 'JOIN', [
'bl_target=bt_id'
] ]
]
);
}
if ( $wgContribScoreIgnoreBots ) {
$sqlWhere[] = "{$revUser} NOT IN " .
$dbr->buildSelectSubquery( 'user_groups', 'ug_user', [ 'ug_group' => 'bot' ], __METHOD__ );
$dbr->buildSelectSubquery( 'user_groups', 'ug_user', [
'ug_group' => 'bot',
'ug_expiry IS NULL OR ug_expiry >= ' . $dbr->addQuotes( $dbr->timestamp() )
], __METHOD__ );
}
if ( count( $wgContribScoreIgnoreUsernames ) ) {
$listIgnoredUsernames = $dbr->makeList( $wgContribScoreIgnoreUsernames );
$sqlWhere[] = "{$revUsername} NOT IN ($listIgnoredUsernames)";
}
if ( $dbr->unionSupportsOrderAndLimit() ) {
$order = [
'GROUP BY' => $revUser,
'GROUP BY' => 'rev_user',
'ORDER BY' => 'page_count DESC',
'LIMIT' => $limit
];
} else {
$order = [ 'GROUP BY' => $revUser ];
$order = [ 'GROUP BY' => 'rev_user' ];
}
$sqlMostPages = $dbr->selectSQLText(
$revQuery['tables'],
[
'rev_user' => $revUser,
'page_count' => 'COUNT(DISTINCT rev_page)',
'rev_count' => 'COUNT(rev_id)',
],
$sqlVars,
$sqlWhere,
__METHOD__,
$order,
@ -87,22 +171,12 @@ class ContributionScores extends IncludableSpecialPage {
);
if ( $dbr->unionSupportsOrderAndLimit() ) {
$order = [
'GROUP BY' => 'rev_user',
'ORDER BY' => 'rev_count DESC',
'LIMIT' => $limit
];
} else {
$order = [ 'GROUP BY' => 'rev_user' ];
$order['ORDER BY'] = 'rev_count DESC';
}
$sqlMostRevs = $dbr->selectSQLText(
$revQuery['tables'],
[
'rev_user' => $revUser,
'page_count' => 'COUNT(DISTINCT rev_page)',
'rev_count' => 'COUNT(rev_id)',
],
$sqlVars,
$sqlWhere,
__METHOD__,
$order,
@ -127,7 +201,6 @@ class ContributionScores extends IncludableSpecialPage {
__METHOD__,
[
'ORDER BY' => 'wiki_rank DESC',
'GROUP BY' => 'user_name',
'LIMIT' => $limit,
],
[
@ -137,6 +210,25 @@ class ContributionScores extends IncludableSpecialPage {
]
]
);
$ret = iterator_to_array( $res );
return $ret;
}
/// Generates a "Contribution Scores" table for a given LIMIT and date range
/**
* Function generates Contribution Scores tables in HTML format (not wikiText)
*
* @param int $days Days in the past to run report for
* @param int $limit Maximum number of users to return (default 50)
* @param string|null $title The title of the table
* @param array $options array of options (default none; nosort/notools)
* @return string Html Table representing the requested Contribution Scores.
*/
function genContributionScoreTable( $days, $limit, $title = null, $options = 'none' ) {
global $wgContribScoresUseRealName, $wgContribScoreCacheTTL;
$opts = explode( ',', strtolower( $options ) );
$sortable = in_array( 'nosort', $opts ) ? '' : ' sortable';
@ -148,11 +240,26 @@ class ContributionScores extends IncludableSpecialPage {
Html::element( 'th', [], $this->msg( 'contributionscores-changes' )->text() ) .
Html::element( 'th', [], $this->msg( 'contributionscores-username' )->text() );
$cache = MediaWikiServices::getInstance()->getMainWANObjectCache();
$data = $cache->getWithSetCallback(
$cache->makeKey( 'contributionscores', 'data-' . (string)$days ),
$wgContribScoreCacheTTL * 60,
function () use ( $days ) {
// Use max limit, as limit doesn't matter with performance.
// Avoid purge multiple times since limit on transclusion can be vary.
return self::getContributionScoreData( $days, self::CONTRIBUTIONSCORES_MAXINCLUDELIMIT );
} );
$lang = $this->getLanguage();
$altrow = '';
$user_rank = 1;
$lang = $this->getLanguage();
foreach ( $res as $row ) {
foreach ( $data as $row ) {
if ( $user_rank > $limit ) {
break;
}
// Use real name if option used and real name present.
if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) {
$userLink = Linker::userLink(
@ -170,7 +277,7 @@ class ContributionScores extends IncludableSpecialPage {
$output .= Html::closeElement( 'tr' );
$output .= "<tr class='{$altrow}'>\n" .
"<td class='content' style='padding-right:10px;text-align:right;'>" .
$lang->formatNum( round( $user_rank, 0 ) ) .
$lang->formatNum( $user_rank ) .
"\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
$lang->formatNum( round( $row->wiki_rank, 0 ) ) .
"\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
@ -198,8 +305,7 @@ class ContributionScores extends IncludableSpecialPage {
$output .= Html::closeElement( 'tr' );
$output .= Html::closeElement( 'table' );
$dbr->freeResult( $res );
// Transcluded on a normal wiki page.
if ( !empty( $title ) ) {
$output = Html::rawElement( 'table',
[
@ -257,7 +363,7 @@ class ContributionScores extends IncludableSpecialPage {
}
}
if ( empty( $limit ) || $limit < 1 || $limit > CONTRIBUTIONSCORES_MAXINCLUDELIMIT ) {
if ( empty( $limit ) || $limit < 1 || $limit > self::CONTRIBUTIONSCORES_MAXINCLUDELIMIT ) {
$limit = 10;
}
if ( $days === null || $days < 0 ) {
@ -300,7 +406,7 @@ class ContributionScores extends IncludableSpecialPage {
$out->addWikiMsg( 'contributionscores-info' );
foreach ( $wgContribScoreReports as $scoreReport ) {
list( $days, $revs ) = $scoreReport;
[ $days, $revs ] = $scoreReport;
if ( $days > 0 ) {
$reportTitle = $this->msg( 'contributionscores-days' )->numParams( $days )->text();
} else {
@ -316,6 +422,14 @@ class ContributionScores extends IncludableSpecialPage {
}
}
public function maxIncludeCacheTime() {
global $wgContribScoreDisableCache, $wgContribScoreCacheTTL;
return $wgContribScoreDisableCache ? 0 : $wgContribScoreCacheTTL;
}
/**
* @inheritDoc
*/
protected function getGroupName() {
return 'wiki';
}