{$old_rank} or {rank} in stats.html

Morus

www.votezone.eu , www.privateserversranking.com
Hi guys,

for some reason the rank is showing me different ranking number between the main page and stats.html.

for example on Main Page L2Interlude.net is on 3rd place (see attached image) when on stats page (http://www.l2.votezone.eu/stats/L2Interlude/ ) it has 5th place. I'm using {$old_rank} to show current ranking on stats.html cause {$rank} is not showing me any ranking number at all on stats.html. Any advice? I need to sort this out cause it is giving my members false info.
 

Attachments

Mark

Administrator
Staff member
{$old_rank} = the last rank value that was cached (used to determine movement ip/down/no change when compared to current rank)

{$rank} = only used in rankings, calculated dynamically. This tag is not intended to be used on the stats page, you would need to create a plugin to recalculate the real rank values on stats pages, you can look at the code used in sources/rankings.php to establish what you need to do.
 

Morus

www.votezone.eu , www.privateserversranking.com
{$old_rank} = the last rank value that was cached (used to determine movement ip/down/no change when compared to current rank)
if that is cached, it needs to do every minutes, hours, dayly, etc. Can I change the catch time for {$old_rank} ?
 

Basti

Administrator
Staff member
It appears old_rank could be improoved a bit, as you can see here in rankings.php it only updates the old_rank if old_rank previously not existed. After that it seems to never update again
Code:
        if ($CONF['ranking_method'] == $ranking_method && $is_main) {
          if (!$TMPL['old_rank']) {
            $TMPL['old_rank'] = $TMPL['rank'];
            $DB->query("UPDATE {$CONF['sql_prefix']}_stats SET old_rank = {$TMPL['old_rank']} WHERE username = '{$TMPL['username']}'", __FILE__, __LINE__);
          }
          if ($TMPL['old_rank'] > $TMPL['rank']) { $TMPL['up_down'] = 'up'; $LNG['up_down'] = $LNG['table_up']; }
          elseif ($TMPL['old_rank'] < $TMPL['rank']) { $TMPL['up_down'] = 'down'; $LNG['up_down'] = $LNG['table_down']; }
          else { $TMPL['up_down'] = 'neutral'; $LNG['up_down'] = $LNG['table_neutral']; }
        }
If you update this block to the following, let me know if it change anything
Code:
        if ($CONF['ranking_method'] == $ranking_method && $is_main) {
          if (!$TMPL['old_rank']) {
            $TMPL['old_rank'] = $TMPL['rank'];
            $DB->query("UPDATE {$CONF['sql_prefix']}_stats SET old_rank = {$TMPL['old_rank']} WHERE username = '{$TMPL['username']}'", __FILE__, __LINE__);
          }
          if ($TMPL['old_rank'] > $TMPL['rank']) {
            $TMPL['up_down'] = 'up'; $LNG['up_down'] = $LNG['table_up'];
            $DB->query("UPDATE {$CONF['sql_prefix']}_stats SET old_rank = {$TMPL['rank']} WHERE username = '{$TMPL['username']}'", __FILE__, __LINE__);
          }
          elseif ($TMPL['old_rank'] < $TMPL['rank']) {
            $TMPL['up_down'] = 'down'; $LNG['up_down'] = $LNG['table_down'];
            $DB->query("UPDATE {$CONF['sql_prefix']}_stats SET old_rank = {$TMPL['rank']} WHERE username = '{$TMPL['username']}'", __FILE__, __LINE__);
          }
          else { $TMPL['up_down'] = 'neutral'; $LNG['up_down'] = $LNG['table_neutral']; }
 
        }
Can still be handled a bit better, as it will produce more mysql queries, but for now that should more properbly update old_rank
 

Morus

www.votezone.eu , www.privateserversranking.com
if I will refresh main page the up/down/neutral images are changing to neutral.
 

Basti

Administrator
Staff member
Ah yea, because old_rank is now same as rank. needs some deeper thinking, pls revert back
 
Top