r56349 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56348‎ | r56349 | r56350 >
Date:23:47, 14 September 2009
Author:nimishg
Status:ok
Tags:
Comment:
Moved UserDailyContribs (table to measure user daily contributions) to its own extension
Modified paths:
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/UserDailyContribs.sql (deleted) (history)
  • /trunk/extensions/UsabilityInitiative/UserDailyContribs (added) (history)
  • /trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.hooks.php (added) (history)
  • /trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.php (added) (history)
  • /trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql (added) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql
@@ -0,0 +1,19 @@
 2+--
 3+-- Schema for UserDailyContribs
 4+--
 5+-- Used in clicktracking to determine how active the user is
 6+--
 7+
 8+CREATE TABLE IF NOT EXISTS /*_*/user_daily_contribs (
 9+ -- user id
 10+ user_id integer NOT NULL default 0,
 11+
 12+ -- day
 13+ day DATE NOT NULL,
 14+
 15+ -- contributions on that day by that user
 16+ contribs integer NOT NULL default 0,
 17+
 18+ -- a unique entry for a given user_id and day
 19+ PRIMARY KEY(user_id, day)
 20+) /*$wgDBTableOptions*/;
\ No newline at end of file
Property changes on: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.sql
___________________________________________________________________
Name: svn:eol-style
121 + native
Index: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.php
@@ -0,0 +1,41 @@
 2+<?php
 3+/**
 4+ * Usability Initiative User Daily Contribtions (for Click Tracking) extension
 5+ *
 6+ * @file
 7+ * @ingroup Extensions
 8+ *
 9+ * This file contains the include file for the User Daily Contributions table in the
 10+ * UsabilityInitiative extension of MediaWiki.
 11+ *
 12+ * Usage: Include the following line in your LocalSettings.php
 13+ * require_once( "$IP/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.php" );
 14+ *
 15+ * @author Nimish Gautam <ngautam@wikimedia.org>
 16+ * @license GPL v2 or later
 17+ * @version 0.1.1
 18+ */
 19+
 20+/* Configuration */
 21+
 22+// Credits
 23+$wgExtensionCredits['other'][] = array(
 24+ 'path' => __FILE__,
 25+ 'name' => 'User Daily Contributions',
 26+ 'author' => 'Nimish Gautam',
 27+ 'version' => '0.1.1',
 28+ 'url' => 'http://www.mediawiki.org/wiki/Extension:UsabilityInitiative'
 29+);
 30+
 31+
 32+
 33+// Includes parent extension
 34+require_once( dirname( dirname( __FILE__ ) ) . "/UsabilityInitiative.php" );
 35+
 36+// Adds Autoload Classes
 37+$dir = dirname( __FILE__ ) . '/';
 38+$wgAutoloadClasses['UserDailyContribsHooks'] = $dir . 'UserDailyContribs.hooks.php';
 39+
 40+// Hooked functions
 41+$wgHooks['LoadExtensionSchemaUpdates'][] = 'UserDailyContribsHooks::schema';
 42+$wgHooks['ArticleSaveComplete'][] = 'UserDailyContribsHooks::storeNewContrib';
Property changes on: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.php
___________________________________________________________________
Name: svn:eol-style
143 + native
Index: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.hooks.php
@@ -0,0 +1,47 @@
 2+<?php
 3+
 4+/**
 5+ * Hooks for Usability Initiative UserDailyContribs extension
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ */
 10+
 11+class UserDailyContribsHooks {
 12+
 13+ public static function schema() {
 14+ global $wgExtNewTables;
 15+
 16+ $wgExtNewTables[] = array(
 17+ 'user_daily_contribs',
 18+ dirname( __FILE__ ) . '/UserDailyContribs.sql'
 19+ );
 20+
 21+ return true;
 22+ }
 23+
 24+
 25+ /**
 26+ * Stores a new contribution
 27+ * @return true
 28+ */
 29+ public static function storeNewContrib(){
 30+ global $wgUser;
 31+ $today = gmdate( 'Ymd', time() );
 32+ $dbw = wfGetDB( DB_MASTER );
 33+ /*
 34+ //there seems no way to set contribs to contribs+1 in a reasonably fast manner in this framework
 35+ try{
 36+ $dbw->insert("user_daily_contribs", array("user_id" => $wgUser->getId(), "day" => $today, "contribs" => 1), __METHOD__);
 37+ }
 38+ catch(Exception $e){
 39+ $dbw->update( "user_daily_contribs", array( "contribs" => "contribs+1"), array("user_id" => $wgUser->getId(), "day" => $today), __METHOD__);
 40+ }
 41+ */
 42+ $sql =
 43+ "INSERT INTO user_daily_contribs (user_id,day,contribs) VALUES ({$wgUser->getId()},$today,1) ON DUPLICATE KEY UPDATE contribs=contribs+1;";
 44+ $dbw->query($sql, __METHOD__);
 45+ return true;
 46+ }
 47+
 48+}
\ No newline at end of file
Property changes on: trunk/extensions/UsabilityInitiative/UserDailyContribs/UserDailyContribs.hooks.php
___________________________________________________________________
Name: svn:eol-style
149 + native
Index: trunk/extensions/UsabilityInitiative/ClickTracking/UserDailyContribs.sql
@@ -1,19 +0,0 @@
2 -
3 -CREATE TABLE IF NOT EXISTS /*_*/user_daily_contribs (
4 - -- user id
5 - user_id integer NOT NULL default 0,
6 -
7 - -- day
8 - day DATE NOT NULL,
9 -
10 - -- contributions on that day by that user
11 - contribs integer NOT NULL default 0,
12 -
13 - -- a unique entry for a given user_id and day
14 - PRIMARY KEY(user_id, day)
15 -) /*$wgDBTableOptions*/;
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php
@@ -23,11 +23,6 @@
2424 );
2525
2626 $wgExtNewTables[] = array(
27 - 'user_daily_contribs',
28 - dirname( __FILE__ ) . '/UserDailyContribs.sql'
29 - );
30 -
31 - $wgExtNewTables[] = array(
3227 'click_tracking_events',
3328 dirname( __FILE__ ) . '/ClickTrackingEvents.sql'
3429 );
@@ -112,20 +107,6 @@
113108 return $edits;
114109 }
115110
116 - /**
117 - * Stores a new contribution
118 - * @return true
119 - */
120 - public static function storeNewContrib(){
121 - global $wgUser;
122 - $today = gmdate( 'Ymd', time() );
123 - $dbw = wfGetDB( DB_MASTER );
124 - $sql =
125 - "INSERT INTO user_daily_contribs (user_id,day,contribs) VALUES ({$wgUser->getId()},$today,1) ON DUPLICATE KEY UPDATE contribs=contribs+1;";
126 - $dbw->query($sql, __METHOD__);
127 -
128 - return true;
129 - }
130111
131112 /**
132113 * Get event ID from name
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.php
@@ -53,7 +53,6 @@
5454
5555 // Hooked functions
5656 $wgHooks['LoadExtensionSchemaUpdates'][] = 'ClickTrackingHooks::schema';
57 -$wgHooks['ArticleSaveComplete'][] = 'ClickTrackingHooks::storeNewContrib';
5857 $wgHooks['EditPage::showEditForm:initial'][] = 'ClickTrackingHooks::addJS';
5958
6059 // Set up the new API module

Follow-up revisions

RevisionCommit summaryAuthorDate
r56354Follow-up r56349: Add desc message to extension credits, add i18n file and ad...raymond10:13, 15 September 2009

Status & tagging log