"Awjrichards" changed the status of MediaWiki.r105641 to "fixme" and commented 
it.
URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/105641#c27688

Old Status: resolved
> New Status: fixme

Commit summary for MediaWiki.r105641:

an initial implementation of a stats summary system. not yet integrated into 
any of the special pages

Awjrichards's comment:

I should've caught this the first time around but it just occurred to me that 
this is not going to work as expected the way things are currently set up:
<pre>
+               $this->dbr = wfGetDB( DB_SLAVE );
+               $this->dbw = wfGetDB( DB_MASTER );
<snip>
+               // Get the data for a fundraiser
+               $result = $this->dbr->select( 'public_reporting',
+                       array(
+                               "DATE_FORMAT( FROM_UNIXTIME( received 
),'%Y-%m-%d' ) AS date",
+                               'sum( converted_amount ) AS total',
+                               'count( * ) AS number',
+                               'avg( converted_amount ) AS average',
+                               'max( converted_amount ) AS maximum',
+                       ),
+                       $conditions,
+                       __METHOD__,
+                       array(
+                               'ORDER BY' => 'received',
+                               'GROUP BY' => "DATE_FORMAT( FROM_UNIXTIME( 
received ),'%Y-%m-%d' )"
+                       )
+               );
</pre>

The public_reporting table is NOT in the wiki's db. There is a function in 
ContributionReporting.php that will build you a db connection to the db that 
holds the public reporting table - efContributionReportingConnection(). We'll 
need to decide whether or not adding the summary tables to the wiki's db is the 
appropriate thing to do, or if it makes more sense to leave in the same place 
as public_reporting. If you want to keep the summary tables in the wiki's db 
you could just create another db object to fetch data from public_reporting and 
leave the dbr/dbw as they are. IMHO it's probably better to keep the summary 
tables in the wiki's db - if that's the road we go down, you could revise this 
to be something like:
<pre>
+               $this->dbr = wfGetDB( DB_SLAVE );
+               $this->dbw = wfGetDB( DB_MASTER );
                $this->dbpr = efContributionReportingConnection();
<snip>
+               // Get the data for a fundraiser
+               $result = $this->dbpr->select( 'public_reporting',
+                       array(
+                               "DATE_FORMAT( FROM_UNIXTIME( received 
),'%Y-%m-%d' ) AS date",
+                               'sum( converted_amount ) AS total',
+                               'count( * ) AS number',
+                               'avg( converted_amount ) AS average',
+                               'max( converted_amount ) AS maximum',
+                       ),
+                       $conditions,
+                       __METHOD__,
+                       array(
+                               'ORDER BY' => 'received',
+                               'GROUP BY' => "DATE_FORMAT( FROM_UNIXTIME( 
received ),'%Y-%m-%d' )"
+                       )
+               );
</pre>
Repeat replacing $this->dbr with $this->dbpr everywhere you're fetching data 
from public reporting and leave the rest as-is.

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to