Page 1 of 2
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 12:50
by doktornotor
Views goal 1000 | Total views 34869 | Remaining
-33869 |
3,487% (red bar)
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 12:54
by Stoker
Hmm, you should have the same files I have:
http://easycaptures.com/6824988521
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 13:00
by doktornotor
Well, I have whatever comes with latest version.
Code: Select all
if (!empty($config['forum_goals_views_enable']) && $config['forum_goals_views'] > 0)
{
$sql = 'SELECT SUM(topic_views) AS count
FROM ' . TOPICS_TABLE . '
WHERE topic_approved = 1';
$result = $db->sql_query($sql);
$total_views = (int) $db->sql_fetchfield('count');
$forum_goals_views_percent = ($total_views * 100) / $config['forum_goals_views'];
$forum_goals_views_rest = $config['forum_goals_views'] - $total_views;
Note that this will go to negative figures per the last line.
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 13:11
by doktornotor
Important note - this bug only appears if the goal has been exceeded by huge margin of %. E.g., - Views goal 20000 | Total views 34870 | Goal reached! | 174% (green) - the bug does not appear. Remove two zeros or so from your goal and you should see it.
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 13:14
by Stoker
Oh, have you refreshed the templates?
We have this in the template which should prevent it:
Code: Select all
<!-- IF FORUM_VIEW_PERCENT < 100 -->{L_GOAL_REMAINING} <strong>{FORUM_VIEW_REST}</strong><!-- ELSE --><em>{L_GOAL_REMAINING_ZERO}</em> <img src="{ROOT_PATH}images/forum_goal_ok.png" width="12" height="12" alt="" /><!-- ENDIF -->
and this in the php files:
'FORUM_VIEW_PERCENT' => number_format($forum_goals_views_percent),
which should prevent the "precise" number.
EDIT: your are right. I will have a look.
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 13:19
by doktornotor
Heh, yeah, weird one... Only discovered it by chance, since I have mistaken the views goal count for the users goal count.
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 13:23
by Stoker
The problem is number format percent: 'FORUM_VIEW_PERCENT' => $forum_goals_views_percent,
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 14:14
by Stoker
Please test round: 'FORUM_VIEW_PERCENT' => round($forum_goals_views_percent),
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 15:54
by doktornotor
OK, tried with both "normal" and extremely low/high goal numbers and seems the
percentage bug is gone!
But the negative numbers remain: Post goal 1 | Total posts 617 | Remaining -616 | 61,700%
[1.0.2] Views goal percentage messed up when goal reached
Posted: 03 Dec 2011, 15:56
by Stoker
You also have to repplace the other instances of number_format with round.