r81349 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81348‎ | r81349 | r81350 >
Date:23:22, 1 February 2011
Author:tparscal
Status:ok
Tags:
Comment:
Added global getUserEditCountSince function so extensions don't have to copy-past this common bit of code.
Modified paths:
  • /trunk/extensions/UserDailyContribs/UserDailyContribs.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UserDailyContribs/UserDailyContribs.php
@@ -28,3 +28,30 @@
2929 $wgHooks['LoadExtensionSchemaUpdates'][] = 'UserDailyContribsHooks::loadExtensionSchemaUpdates';
3030 $wgHooks['ArticleSaveComplete'][] = 'UserDailyContribsHooks::articleSaveComplete';
3131 $wgHooks['ParserTestTables'][] = 'UserDailyContribsHooks::parserTestTables';
 32+
 33+/**
 34+ * Get the number of revisions a user has made since a given time
 35+ *
 36+ * @param $time beginning timestamp
 37+ * @return number of revsions this user has made
 38+ */
 39+function getUserEditCountSince( $time = null, User $user = null ) {
 40+ global $wgUser;
 41+
 42+ // Fallback on current user
 43+ if ( is_null( $user ) ) {
 44+ $user = $wgUser;
 45+ }
 46+ // Round time down to a whole day
 47+ $time = gmdate( 'Y-m-d', wfTimestamp( TS_UNIX, $time ) );
 48+ // Query the user contribs table
 49+ $dbr = wfGetDB( DB_SLAVE );
 50+ $edits = $dbr->selectField(
 51+ 'user_daily_contribs',
 52+ 'SUM(contribs)',
 53+ array( 'user_id' => $user->getId(), 'day >= ' . $dbr->addQuotes( $time ) ),
 54+ __METHOD__
 55+ );
 56+ // Return edit count as an integer
 57+ return is_null( $edits ) ? 0 : (integer) $edits;
 58+}

Follow-up revisions

RevisionCommit summaryAuthorDate
r81352Made use of new getUserEditCountSince function introduced in r81349.tparscal23:23, 1 February 2011
r814131.17: MFT r78395, r79968, r81311, r81313, r81349, r81352, r81376, r81389, r81...catrope20:45, 2 February 2011

Status & tagging log