Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/247512
Change subject: Real-time active editor metrics ...................................................................... Real-time active editor metrics Whenever a non-bot user edits a mainspace page, enqueue a deferred update which checks if the edit is the fifth such edit by this user this month. If it is, then the user now counts as an "active editor", per the metric defined at https://www.mediawiki.org/wiki/Analytics/Metric_definitions#Active_editor. Log an event and increment a stat. Depends on change I8c0a93713c1 in mediawiki/core. Change-Id: I370589c77059a4ae5b8e607285cd95587e43d6b7 --- M WikimediaEventsHooks.php 1 file changed, 36 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents refs/changes/12/247512/1 diff --git a/WikimediaEventsHooks.php b/WikimediaEventsHooks.php index bd71292..8a69a2e 100644 --- a/WikimediaEventsHooks.php +++ b/WikimediaEventsHooks.php @@ -77,6 +77,8 @@ return; } + $userId = $user->getId(); + // Get the user's age, measured in seconds since registration. $age = time() - wfTimestampOrNull( TS_UNIX, $user->getRegistration() ); @@ -94,6 +96,40 @@ $stats->timing( "editor.milestones.timing.{$milestone}", $age ); } + // Check if this edit is the fifth mainspace edit this month by this + // user. If it is, then the user has just become an active editor for + // this month. Emit an event and increment a stat. + // + // @see https://www.mediawiki.org/wiki/Analytics/Metric_definitions#Active_editor + if ( + $title->inNamespace( NS_MAIN ) && + $editCount >= 4 && + !$user->isAllowed( 'bot' ) + ) { + DeferredUpdates::addCallableUpdate( function () use ( $userId ) { + $db = wfGetDB( DB_MASTER ); + $monthlyEditCount = $db->selectRowCount( + array( 'revision', 'page' ), + '1', + array( + 'rev_user' => $userId, + 'rev_timestamp >= ' . $db->addQuotes( date( 'Ym' ) . '00000000' ), + 'page_namespace' => NS_MAIN, + ), + 'WikimediaEventsHooks::onPageContentSaveComplete', + array( 'LIMIT' => 6 ), + array( 'page' => array( 'INNER JOIN', 'rev_page = page_id' ) ) + ); + if ( $monthlyEditCount === 5 ) { + $month = date( 'm-Y' ); + RequestContext::getMain()->getStats()->increment( + "editor.activation.{$month}" ); + EventLogging::logEvent( 'EditorActivation', 14208804, + array( 'userId' => $userId, 'month' => $month ) ); + } + } ); + } + // If the editor signed up in the last thirty days, and if this is an // NS_MAIN edit, log a NewEditorEdit event. if ( $age <= 2592000 && $title->inNamespace( NS_MAIN ) ) { -- To view, visit https://gerrit.wikimedia.org/r/247512 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I370589c77059a4ae5b8e607285cd95587e43d6b7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikimediaEvents Gerrit-Branch: master Gerrit-Owner: Ori.livneh <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
