Extension talk:Contribution Scores

Jump to: navigation, search

About this board

Archive


86.61.12.125 (talkcontribs)

With enabled $wgShowSQLErrors in LocalSettings.php:

A database query syntax error has occurred. This may indicate a bug in the software. The last attempted database query was:


SELECT user_id, user_name, page_count, rev_count, page_count+SQRT(rev_count-page_count)*2 AS wiki_rank FROM user u JOIN ((SELECT rev_user, COUNT(DISTINCT rev_page) AS page_count, COUNT(rev_id) AS rev_count FROM revision WHERE rev_timestamp > '20120925235315' AND rev_user NOT IN (SELECT ipb_user FROM ipblocks WHERE ipb_user <> 0) AND rev_user NOT IN (SELECT ug_user FROM user_groups WHERE ug_group='bot') GROUP BY rev_user ORDER BY page_count DESC LIMIT 50) UNION (SELECT rev_user, COUNT(DISTINCT rev_page) AS page_count, COUNT(rev_id) AS rev_count FROM revision WHERE rev_timestamp > '20120925235315' AND rev_user NOT IN (SELECT ipb_user FROM ipblocks WHERE ipb_user <> 0) AND rev_user NOT IN (SELECT ug_user FROM user_groups WHERE ug_group='bot') GROUP BY rev_user ORDER BY rev_count DESC LIMIT 50)) s ON (user_id=rev_user) ORDER BY wiki_rank DESC LIMIT 50


from within function "". Database returned error "1: near "UNION": syntax error".

12.25.107.2 (talkcontribs)

I am getting the same thing in 1.24

A database query error has occurred. This may indicate a bug in the software.

  • Query:
    SELECT user_id, user_name, user_real_name, page_count, rev_count, page_count+SQRT(rev_count-page_count)*2 AS wiki_rank FROM user u JOIN ((SELECT rev_user, COUNT(DISTINCT rev_page) AS page_count, COUNT(rev_id) AS rev_count FROM revision WHERE rev_timestamp > '20151203135947' AND rev_user NOT IN (SELECT ipb_user FROM ipblocks WHERE ipb_user <> 0) AND rev_user NOT IN (SELECT ug_user FROM user_groups WHERE ug_group='bot') GROUP BY rev_user ORDER BY page_count DESC LIMIT 50) UNION (SELECT rev_user, COUNT(DISTINCT rev_page) AS page_count, COUNT(rev_id) AS rev_count FROM revision WHERE rev_timestamp > '20151203135947' AND rev_user NOT IN (SELECT ipb_user FROM ipblocks WHERE ipb_user <> 0) AND rev_user NOT IN (SELECT ug_user FROM user_groups WHERE ug_group='bot') GROUP BY rev_user ORDER BY rev_count DESC LIMIT 50)) s ON (user_id=rev_user) ORDER BY wiki_rank DESC LIMIT 50
  • Function: DatabaseBase::query
  • Error: 1 near "UNION": syntax error
Reply to "Critical: Does not work in 1.18"
Stuartbman (talkcontribs)

Just in case anyone is looking for a way to hide columns when inserting the table into pages, this can be added into Common.css:

.contributionscores td:nth-child(2) {     display:none; } .contributionscores .header th:nth-child(2) {     display:none; }

Reply to "Hiding columns"
Berrygator (talkcontribs)

I want to be able to rank people by how many words they have contributed. People adding files and making small changes is distorting the rankings from showing the true Top Contributors on my Wiki. Is this possible?

Fbstj (talkcontribs)

that would be so awesome

Reply to "Rank by Words Added"
Rbirmann (talkcontribs)

Hi,

First of all, just wanted to say this extension is great.

We have installed it in our corporate wiki, as part of an internal program to motivate users to contribute to it. We would like, however, to give more points to users who create new articles as well as to differentiate longer, well thought, editions (such as a 5 paragraph long new section on an article) from shorter, quicker, less relevant changes (such as a one letter typo correction).

While thinking about this it came to me that maybe it is possible to allow users to create, on their LocalSettings.php a custom calculating function. I am no php expert myself, so please see the pseudo-code below:

on the extension itself:


efContributionScores_Render (...)
  
  for u in all_users do

    new_articles = countNewArticles(u)
    total_edits = countTotalEdits(u)
    unique_edits = countUniquePageEdits(u)
    other_data = countOtherRelevantData(u)
    (...)

    if function_exists "csCustomUserCalculation" then

      score[u] = csCustomUserCalculation (new_articles, total_edits, unique_edits, other_data)

    else

      score[u] = unique_edits + 2 * sqrt(total_edits - unique_edits)    // default behaviour
  
    end if

  end for

return score


Users would then be able to add a custom way of calculating scores to their LocalSettings, something like this (again in pseudo-code):


csCustomUserCalculation (new_articles, total_edits, unique_edits, ...)

    score = 10 * new_articles + total_edits

return score

Any thoughts???

Rbirmann (talk) 16:10, 22 January 2015 (UTC)

Reply to "change the way score is calculated"

Contribution score for a transcribing page.

1
208.116.10.33 (talkcontribs)

Is there a way to identify the contributions by users in all the transcribing pages? For that how to add the cscore to the page: template? I have no idea how to implement this.

Reply to "Contribution score for a transcribing page."

How to display the score after user page title.

2
Rob Kam (talkcontribs)

To give more prominence to this feature on a wiki. Is there a way to have the user's score appended to the name of their user page?

Rob Kam (talkcontribs)

This doesn't work but it would be something like, first add to LocalSettings.php:

$wgRestrictDisplayTitle = false;

Then on the user page add:

{{DISPLAYTITLE:{{BASEPAGENAME}}&nbsp;{{#cscore:{{BASEPAGENAME}}|score}}}}
Reply to "How to display the score after user page title."
79.228.75.218 (talkcontribs)

Wouldn't it be good to store queries in memcached?

Reply to "Memcached"
Mattsmith321 (talkcontribs)

I wanted a column to show the user's rank in the table. That way it is a little easier to see where you stand in a list of 50 people. The Score column is great and is what is used for Rank but if people start raising their Score they still need an easy way to see if they are improving their relative position among the other editors.

I made the following changes in ContributionsScore_body.php (lines 107-145):

Old code:

		$altrow = '';

		foreach ( $res as $row ) {
			// Use real name if option used and real name present.
			if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) {
				$userLink = Linker::userLink(
					$row->user_id,
					$row->user_name,
					$row->user_real_name
				);
			} else {
				$userLink = Linker::userLink(
					$row->user_id,
					$row->user_name
				);
			}

			$output .= Html::closeElement( 'tr' );
			$output .= "<tr class='{$altrow}'>\n<td class='content'>" .
				$wgLang->formatNum( round( $row->wiki_rank, 0 ) ) . "\n</td><td class='content'>" .
				$wgLang->formatNum( $row->page_count ) . "\n</td><td class='content'>" .
				$wgLang->formatNum( $row->rev_count ) . "\n</td><td class='content'>" .
				$userLink;

			# Option to not display user tools
			if ( !in_array( 'notools', $opts ) ) {
				$output .= Linker::userToolLinks( $row->user_id, $row->user_name );
			}

			$output .= Html::closeElement( 'td' ) . "\n";

			if ( $altrow == '' && empty( $sortable ) ) {
				$altrow = 'odd ';
			} else {
				$altrow = '';
			}
		}

New code:

		$altrow = '';
		$userRank = 1;

		foreach ( $res as $row ) {
			// Use real name if option used and real name present.
			if ( $wgContribScoresUseRealName && $row->user_real_name !== '' ) {
				$userLink = Linker::userLink(
					$row->user_id,
					$row->user_name,
					$row->user_real_name
				);
			} else {
				$userLink = Linker::userLink(
					$row->user_id,
					$row->user_name
				);
			}

			$output .= Html::closeElement( 'tr' );
			$output .= "<tr class='{$altrow}'>\n<td class='content' style='padding-right:10px;text-align:right;'>" .
				$wgLang->formatNum( round( $userRank, 0 ) ) . "\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
				$wgLang->formatNum( round( $row->wiki_rank, 0 ) ) . "\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
				$wgLang->formatNum( $row->page_count ) . "\n</td><td class='content' style='padding-right:10px;text-align:right;'>" .
				$wgLang->formatNum( $row->rev_count ) . "\n</td><td class='content'>" .
				$userLink;

			# Option to not display user tools
			if ( !in_array( 'notools', $opts ) ) {
				$output .= Linker::userToolLinks( $row->user_id, $row->user_name );
			}

			$output .= Html::closeElement( 'td' ) . "\n";

			if ( $altrow == '' && empty( $sortable ) ) {
				$altrow = 'odd ';
			} else {
				$altrow = '';
			}
			$userRank++;
		}

In addition to the new column, I right-justified the numeric columns. Keep in mind that this code is not fully-baked in that there are several items that are hard-coded.

Enjoy!

Nemo bis (talkcontribs)

Hi! Thank you for sharing your patch, could you please add it to our repository? See Git/Tutorial.

Mattsmith321 (talkcontribs)

Trying to get it added. I am struggling with the git-review piece of gerrit in a Windows world. I've got my changes committed locally and ready to push but getting stuck on needing the change-id. I will have to try it later when I have a little more time to work through it.

Mattsmith321 (talkcontribs)

Holy cow! I think I actually got it submitted. You will definitely want to review everything. Let me know if there are any issues or what I might have done wrong so that I can do better next time.

Thanks!

Mattsmith321 (talk) 15:31, 23 September 2013 (UTC)

Nemo bis (talkcontribs)

Thanks for sending it. We know that it's hard for Windows users. :(

Reply to "Add column for rank"
Peachey88 (Flood) (talkcontribs)

This is a nice extension that has motivated my users to contribute. Unfortunately the scores are bloated by image uploads which each count as a page. Could you please add an option to limit or include only certain namespaces, for example Main only, or excluding File namespace. I think this would be an easy addition to the SQL as the field is in the page table.

Stefahn (talkcontribs)

Bumping this since I also would love to exclude a certain namespace from the scores.
Does anyone know how to do this? I'm not familiar with MySQL yet...

Mattsmith321 (talkcontribs)

+1 for having some flexibility to include/exclude edits by namespace. In our case, at a bare minimum edits to the User namespace need to be excluded.

Mattsmith321 (talkcontribs)

Here is what I did:

In ContributionScores_body.php, replace the following code (lines 61-77):

		$sqlMostPages = "SELECT rev_user,
						 COUNT(DISTINCT rev_page) AS page_count,
						 COUNT(rev_id) AS rev_count
						 FROM {$revTable}
						 {$sqlWhere}
						 GROUP BY rev_user
						 ORDER BY page_count DESC
						 LIMIT {$limit}";

		$sqlMostRevs  = "SELECT rev_user,
						 COUNT(DISTINCT rev_page) AS page_count,
						 COUNT(rev_id) AS rev_count
						 FROM {$revTable}
						 {$sqlWhere}
						 GROUP BY rev_user
						 ORDER BY rev_count DESC
						 LIMIT {$limit}";

With the following code:

		$sqlWhere .= " {$nextPrefix} page_namespace IN (0, 4, 10, 12, 14)";
		$nextPrefix = "AND";

		$sqlMostPages = "SELECT rev_user,
						 COUNT(DISTINCT rev_page) AS page_count,
						 COUNT(rev_id) AS rev_count
						 FROM {$revTable}
						 JOIN page ON revision.rev_page = page.page_id
						 {$sqlWhere}
						 GROUP BY rev_user
						 ORDER BY page_count DESC
						 LIMIT {$limit}";

		$sqlMostRevs  = "SELECT rev_user,
						 COUNT(DISTINCT rev_page) AS page_count,
						 COUNT(rev_id) AS rev_count
						 FROM {$revTable}
						 JOIN page ON revision.rev_page = page.page_id
						 {$sqlWhere}
						 GROUP BY rev_user
						 ORDER BY rev_count DESC
						 LIMIT {$limit}";

A couple things to keep in mind with the code change above:

  • It isn't a fully-baked solution. I just slammed in some extra SQL code.
    • The reference to the Page table is hard-coded.
    • The list of desired Namespaces is hard-coded.
  • The solution requires joining on the Page table affects performance. I haven't run any performance tests, but this might not be a good thing to do on a very large wiki.
  • I also updated ContributionScores.i18n.php to indicate that namespaces are used in the calculation. Actually I rewrote the entire description:
	'contributionscores-info'            => "Scores are calculated as follows: <code>Score = Pages + ( Square root of ( Changes - Pages ) * 2 )</code>. 
	Points are only scored for changes in the Main, TMHPWiki, Template, Help or Category namespaces.
	Scores calculated in this manner weight edit diversity over edit volume.
	Basically, this score measures primarily unique pages edited, with consideration for high edit volume - assumed to be a higher quality page.",

Hope this helps someone else. I am definitely more excited about using the extension now. Our wiki training takes place in the User namespace and having those edits included in the Score was just not working out.

Reply to "Namespace Filtering"
195.212.29.90 (talkcontribs)

Hi,

This extension is failing to work in 1.16.

It's failing on a call to getOutput() that seems to have been added in the 1.18 release of mediawiki.

Is there an older SVN revision you can point me to that will work with 1.16?

Nemo bis (talkcontribs)

The REL1_16 branch didn't go anywhere. :)

You should really upgrade, though. Since 1.17 you don't even need command line and it's a single step to 1.20. ;-)

195.212.29.90 (talkcontribs)

Thanks very much.

I will upgrade when I find the time to test everything :-)

Reply to "I can't get this to work in 1.16"