r21753 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r21752‎ | r21753 | r21754 >
Date:15:38, 1 May 2007
Author:aaron
Status:old
Tags:
Comment:
*SQL optimizing
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -282,83 +282,8 @@
283283 // Return count of revisions
284284 return $db->numRows($result);
285285 }
286 -
287 - /**
288 - * Get all the revisions that meet the requirments
289 - * per the $wgFlaggedRevTags variable
290 - * This can become expensive
291 - * @param database $db
292 - * @param int $page_id
293 - * @param int $limit
294 - * @param int $max_rev_id the revision ids should be less than this
295 - */
296 - function getQualityRevisions( $db, $page_id, $limit=1, $max_rev_id=NULL ) {
297 - global $wgFlaggedRevTags;
298286
299 - wfProfileIn( __METHOD__ );
300 -
301 - $tagwhere = array();
302 - // Look for $wgFlaggedRevTags key flags only
303 - foreach ( $wgFlaggedRevTags as $flag => $min) {
304 - $tagwhere[] = '(frt_dimension = ' . $db->addQuotes($flag) . ' AND frt_value >= ' . intval($min) . ')';
305 - }
306 - $tagwhere = implode(' OR ', $tagwhere);
307 - $maxrevid = $max_rev_id ? "frt_rev_id < $max_rev_id" : '1 = 1';
308 - // Skip archived/deleted revs
309 - // Get group rows of the newest flagged revs and the number
310 - // of key flags that were fulfilled
311 - $result = $db->select(
312 - array('flaggedrevtags','flaggedrevs','revision'),
313 - array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp', 'COUNT(*)'),
314 - array('frt_page_id' => $page_id, $tagwhere, $maxrevid, 'frt_rev_id=fr_rev_id', 'fr_rev_id=rev_id', 'rev_deleted=0'),
315 - __METHOD__,
316 - array('GROUP BY' => 'frt_rev_id', 'HAVING' => 'COUNT(*)='.$wgFlaggedRevTags, 'ORDER BY' => 'frt_rev_id DESC', 'LIMIT' => $limit) );
317 - // Iterate through each flagged revision row
318 - $out = array();
319 - while ( $row = $db->fetchObject($result) ) {
320 - $out[] = $row;
321 - }
322 - return $out;
323 - }
324 -
325287 /**
326 - * Get all the revisions that meet the requirments
327 - * per the $wgFlaggedRevTags variable
328 - * This can become expensive, use it if you changed
329 - * your quality criteria
330 - * @param database $db
331 - * @param int $page_id
332 - * @param int $limit
333 - * @param int $max_rev_id the revision ids should be less than this
334 - */
335 - function getStableRevisions( $db, $page_id, $limit=1, $max_rev_id=NULL ) {
336 - global $wgFlaggedRevTags;
337 -
338 - wfProfileIn( __METHOD__ );
339 -
340 - $maxrevid = $max_rev_id ? "fr_rev_id < $max_rev_id" : '1 = 1';
341 - // Skip archived/deleted revs
342 - // Get group rows of the newest flagged revs and the number
343 - // of key flags that were fulfilled
344 - $result = $db->select(
345 - array('flaggedrevs','revision'),
346 - array('fr_rev_id', 'fr_user', 'fr_timestamp', 'fr_comment', 'rev_timestamp'),
347 - array('fr_page_id' => $page_id, $maxrevid, 'fr_rev_id=rev_id', 'rev_deleted=0'),
348 - __METHOD__,
349 - array('ORDER BY' => 'fr_rev_id DESC') );
350 - // Iterate through each flagged revision row
351 - $out = array();
352 - $counter = 0;
353 - while ( $row = $db->fetchObject($result) ) {
354 - // Only return so many results
355 - if ( $counter > $limit ) break;
356 - $out[] = $row;
357 - $counter++;
358 - }
359 - return $out;
360 - }
361 -
362 - /**
363288 * @param int $rev_id
364289 * Return an array output of the flags for a given revision
365290 */
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql
@@ -16,11 +16,11 @@
1717 -- Store the text with all transclusions resolved
1818 -- This will trade space for more speed and reliability
1919 fr_text mediumblob NOT NULL default '',
 20+ -- Store the precedence level
2021 fr_quality tinyint(1) default 0,
21 -
22 - PRIMARY KEY fr_rev_id (fr_rev_id),
23 - UNIQUE KEY (fr_id),
24 - INDEX fr_page_rev (fr_page_id,fr_rev_id)
 22+
 23+ PRIMARY KEY (fr_page_id,fr_rev_id),
 24+ UNIQUE KEY (fr_id)
2525 ) TYPE=InnoDB;
2626
2727 -- This stores all of our tag data
@@ -31,8 +31,8 @@
3232 frt_dimension varchar(255) NOT NULL,
3333 frt_value tinyint(2) NOT NULL,
3434
35 - PRIMARY KEY frt_rev_dimension (frt_rev_id,frt_dimension),
36 - INDEX frt_page_rev_val (frt_page_id,frt_rev_id,frt_dimension,frt_value)
 35+ PRIMARY KEY (frt_rev_id,frt_dimension),
 36+ INDEX frt_rev_dim_val (frt_rev_id,frt_dimension,frt_value)
3737 ) TYPE=InnoDB;
3838
3939 -- For future restrictons