r55460 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r55459‎ | r55460 | r55461 >
Date:23:36, 21 August 2009
Author:nimishg
Status:deferred
Tags:
Comment:
We decided to have 3 levels of granularity instead of just recording user contributions per 6 month period. We get to sift through the data later and figure out which one (if any) was the most useful
Modified paths:
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ApiClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php
@@ -155,10 +155,13 @@
156156 * @param $namespace Integer: namespace the user is editing
157157 * @param $event_id Integer: event type
158158 * @param $contribs Integer: contributions the user has made (or NULL if user not logged in)
159 - * @param $contribs_in_timespan Integer: number of contributions user has made in a given timespan
 159+ * @param $contribs_in_timespan1 Integer: number of contributions user has made in timespan of granularity 1 (defined by ClickTracking/$wgClickTrackContribGranularity1)
 160+ * @param $contribs_in_timespan2 Integer: number of contributions user has made in timespan of granularity 2 (defined by ClickTracking/$wgClickTrackContribGranularity2)
 161+ * @param $contribs_in_timespan3 Integer: number of contributions user has made in timespan of granularity 3 (defined by ClickTracking/$wgClickTrackContribGranularity3)
160162 * @return true if the event was stored in the DB
161163 */
162 - public static function trackEvent( $session_id, $is_logged_in, $namespace, $event_id, $contribs = 0, $contribs_in_timespan = 0 ){
 164+ public static function trackEvent( $session_id, $is_logged_in, $namespace, $event_id, $contribs = 0,
 165+ $contribs_in_timespan1 = 0, $contribs_in_timespan2 = 0, $contribs_in_timespan3 = 0 ){
163166 $dbw = wfGetDB( DB_MASTER );
164167
165168 $dbw->begin();
@@ -168,7 +171,9 @@
169172 'session_id' => (string) $session_id,
170173 'is_logged_in' => (bool) $is_logged_in,
171174 'user_total_contribs' => ( $is_logged_in ? (int) $contribs : null ),
172 - 'user_contribs_span' => ( $is_logged_in ? (int) $contribs_in_timespan : null ),
 175+ 'user_contribs_span1' => ( $is_logged_in ? (int) $contribs_in_timespan1 : null ),
 176+ 'user_contribs_span2' => ( $is_logged_in ? (int) $contribs_in_timespan2 : null ),
 177+ 'user_contribs_span3' => ( $is_logged_in ? (int) $contribs_in_timespan3 : null ),
173178 'namespace' => (int) $namespace,
174179 'event_id' => (int) $event_id
175180 );
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql
@@ -15,8 +15,14 @@
1616 -- total user contributions
1717 user_total_contribs integer,
1818
19 - -- user contributions over a specified timespan
20 - user_contribs_span integer,
 19+ -- user contributions over a specified timespan of granularity 1
 20+ user_contribs_span1 integer,
 21+
 22+ -- user contributions over a specified timespan of granularity 2
 23+ user_contribs_span2 integer,
 24+
 25+ -- user contributions over a specified timespan of granularity 3
 26+ user_contribs_span3 integer,
2127
2228 -- namespace being edited
2329 namespace integer NOT NULL,
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ApiClickTracking.php
@@ -13,7 +13,7 @@
1414 * @see includes/api/ApiBase#execute()
1515 */
1616 public function execute(){
17 - global $wgUser, $wgTitle, $wgClickTrackContribTimeValue;
 17+ global $wgUser, $wgTitle, $wgClickTrackContribGranularity1, $wgClickTrackContribGranularity2, $wgClickTrackContribGranularity3;
1818
1919 $params = $this->extractRequestParams();
2020 $this->validateParams( $params );
@@ -24,6 +24,18 @@
2525 $event_id = ClickTrackingHooks::getEventIDFromName( urldecode( $eventid_to_lookup ) );
2626
2727 $is_logged_in = $wgUser->isLoggedIn();
 28+ $now = time();
 29+ $granularity1 = $is_logged_in?
 30+ ClickTrackingHooks::getEditCountSince( $now - $wgClickTrackContribGranularity1 )
 31+ : 0;
 32+
 33+ $granularity2 = $is_logged_in?
 34+ ClickTrackingHooks::getEditCountSince( $now - $wgClickTrackContribGranularity2 )
 35+ : 0;
 36+
 37+ $granularity3 = $is_logged_in?
 38+ ClickTrackingHooks::getEditCountSince( $now - $wgClickTrackContribGranularity3 )
 39+ : 0;
2840
2941 ClickTrackingHooks::trackEvent(
3042 $session_id, // randomly generated session ID
@@ -31,10 +43,9 @@
3244 $wgTitle->getNamespace(), // what namespace are they editing?
3345 $event_id, // event ID passed in
3446 ( $is_logged_in ? $wgUser->getEditCount() : 0 ), // total edit count or 0 if anonymous
35 - ( $is_logged_in ?
36 - ( ClickTrackingHooks::getEditCountSince( time() - $wgClickTrackContribTimeValue ) )
37 - : 0
38 - ) // contributions since whatever the time value is, or 0 if anonymous
 47+ $granularity1, //contributions made in granularity 1 time frame
 48+ $granularity2, //contributions made in granularity 2 time frame
 49+ $granularity3 //contributions made in granularity 3 time frame
3950 );
4051 }
4152
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php
@@ -22,7 +22,9 @@
2323 $wgClickTrackEnabled = true;
2424
2525 // set the time window for what we consider 'recent' contributions, in days
26 -$wgClickTrackContribTimeValue = 60 * 60 * 24 * 365 / 2; // half a year
 26+$wgClickTrackContribGranularity1 = 60 * 60 * 24 * 365 / 2; // half a year
 27+$wgClickTrackContribGranularity2 =60 * 60 * 24 * 365 / 4; // 1/4 a year (3 months approx)
 28+$wgClickTrackContribGranularity3 = 60 * 60 * 24 * 30; //30 days (1 month approx)
2729
2830 // Credits
2931 $wgExtensionCredits['other'][] = array(

Status & tagging log