
[1.0.2] Views goal percentage messed up when goal reached
Forum rules
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support
You dont have to use ModX or make your mod AutoMod compatible. A simple textfile is fine
But if you post Mods here You also have to give support
[1.0.2] Views goal percentage messed up when goal reached
Views goal 1000 | Total views 34869 | Remaining -33869 | 3,487% (red bar)


[1.0.2] Views goal percentage messed up when goal reached
Hmm, you should have the same files I have: http://easycaptures.com/6824988521
[1.0.2] Views goal percentage messed up when goal reached
Well, I have whatever comes with latest version. 
Note that this will go to negative figures per the last line.

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;
[1.0.2] Views goal percentage messed up when goal reached
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
Oh, have you refreshed the templates?
We have this in the template which should prevent it:
and this in the php files:
EDIT: your are right. I will have a look.
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 -->
'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
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
The problem is number format percent:
'FORUM_VIEW_PERCENT' => $forum_goals_views_percent,
[1.0.2] Views goal percentage messed up when goal reached
Please test round:
'FORUM_VIEW_PERCENT' => round($forum_goals_views_percent),
[1.0.2] Views goal percentage messed up when goal reached
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%


But the negative numbers remain: Post goal 1 | Total posts 617 | Remaining -616 | 61,700%

Last edited by doktornotor on 03 Dec 2011, 13:56, edited 1 time in total.
[1.0.2] Views goal percentage messed up when goal reached
You also have to repplace the other instances of number_format with round.