Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -155,10 +155,13 @@ |
156 | 156 | * @param $namespace Integer: namespace the user is editing |
157 | 157 | * @param $event_id Integer: event type |
158 | 158 | * @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) |
160 | 162 | * @return true if the event was stored in the DB |
161 | 163 | */ |
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 ){ |
163 | 166 | $dbw = wfGetDB( DB_MASTER ); |
164 | 167 | |
165 | 168 | $dbw->begin(); |
— | — | @@ -168,7 +171,9 @@ |
169 | 172 | 'session_id' => (string) $session_id, |
170 | 173 | 'is_logged_in' => (bool) $is_logged_in, |
171 | 174 | '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 ), |
173 | 178 | 'namespace' => (int) $namespace, |
174 | 179 | 'event_id' => (int) $event_id |
175 | 180 | ); |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.sql |
— | — | @@ -15,8 +15,14 @@ |
16 | 16 | -- total user contributions |
17 | 17 | user_total_contribs integer, |
18 | 18 | |
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, |
21 | 27 | |
22 | 28 | -- namespace being edited |
23 | 29 | namespace integer NOT NULL, |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ApiClickTracking.php |
— | — | @@ -13,7 +13,7 @@ |
14 | 14 | * @see includes/api/ApiBase#execute() |
15 | 15 | */ |
16 | 16 | public function execute(){ |
17 | | - global $wgUser, $wgTitle, $wgClickTrackContribTimeValue; |
| 17 | + global $wgUser, $wgTitle, $wgClickTrackContribGranularity1, $wgClickTrackContribGranularity2, $wgClickTrackContribGranularity3; |
18 | 18 | |
19 | 19 | $params = $this->extractRequestParams(); |
20 | 20 | $this->validateParams( $params ); |
— | — | @@ -24,6 +24,18 @@ |
25 | 25 | $event_id = ClickTrackingHooks::getEventIDFromName( urldecode( $eventid_to_lookup ) ); |
26 | 26 | |
27 | 27 | $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; |
28 | 40 | |
29 | 41 | ClickTrackingHooks::trackEvent( |
30 | 42 | $session_id, // randomly generated session ID |
— | — | @@ -31,10 +43,9 @@ |
32 | 44 | $wgTitle->getNamespace(), // what namespace are they editing? |
33 | 45 | $event_id, // event ID passed in |
34 | 46 | ( $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 |
39 | 50 | ); |
40 | 51 | } |
41 | 52 | |
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php |
— | — | @@ -22,7 +22,9 @@ |
23 | 23 | $wgClickTrackEnabled = true; |
24 | 24 | |
25 | 25 | // 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) |
27 | 29 | |
28 | 30 | // Credits |
29 | 31 | $wgExtensionCredits['other'][] = array( |