Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OUGC Awards

Please note that this is pretty much a negative criticism post, rather than a balanced review as mentioned in this thread. Also be aware that stuff posted here may be highly subjective.
Please feel free to criticise this post, however.

Plugin Reviewed: OUGC Awards
Plugin Version: 1.0.2 (last updated 15th April 2012)
Plugin Author: Omar Gonzalez
Author Message
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #3
RE: OUGC Awards
(04-22-2012 09:04 AM)Sama34 Wrote:  And do you really thing it would bring more problems if I cache the users? I did so to void postbit queries at at ll.

Everybody seems to be afraid of plugins that make any extra query by post at postbit.

I also though about adding a user column to save users awards there instead, but to me it looks worse since I use others plugins that do something similar (newpoints, myachievements, etc..).
It's generally a bad idea to query for each post build, eg if there's 20 posts per page, a single query on postbit would add an extra 20 queries to the page load.  2 queries per postbit would be 40 etc.
That doesn't mean you can't query on postbit, you just need to ensure it only executes once.

Eg:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function postbit_hook_function($post) {

  static $awards_cache = null;
  if(!isset($awards_cache[$post['uid']])) {
    global $pids, $db;
    isset($awards_cache) or $awards_cache = array();
    $awards_cache[$post['uid']] = array();
    if(THIS_SCRIPT == 'showthread.php' && $pids) {
      // cache awards here (I'm unsure of this query, cbf checking)
      $query = $db->query('SELECT DISTINCT a.* FROM '.TABLE_PREFIX.'posts p LEFT JOIN '.TABLE_PREFIX.'awards a ON p.uid=a.uid WHERE p.'.$pids);
      while($award = $db->fetch_array($query)) {
        $awards_cache[$award['uid']][$award['aid']] = $award;
      }
      $db->free_result($query);
    } else {
      $query = $db->simple_select('awards', '*', 'uid='.$post['uid']);
      $award = $db->fetch_array($query);
      $awards_cache[$post['uid']] = array($award['aid'] => $award);
    }
  }
  
  // awards now can be referenced through $awards_cache[$post['uid']]
}



Or just cache on the users table, as one could assume that there won't be too many awards.  If you're afraid of conflicting with another plugin, just ensure that your column name is unique.


My Blog
(This post was last modified: 04-22-2012 08:35 PM by ZiNgA BuRgA.)
04-22-2012 08:34 PM
Find all posts by this user Quote this message in a reply


Messages In This Thread
OUGC Awards - ZiNgA BuRgA - 04-19-2012, 05:16 PM
RE: OUGC Awards - Sama34 - 04-22-2012, 09:04 AM
RE: OUGC Awards - ZiNgA BuRgA - 04-22-2012 08:34 PM
RE: OUGC Awards - Sama34 - 04-23-2012, 01:30 PM
RE: OUGC Awards - ZiNgA BuRgA - 04-23-2012, 04:54 PM
RE: OUGC Awards - Sama34 - 04-24-2012, 01:59 PM

Forum Jump: