[1.0.2] Views goal percentage messed up when goal reached
- doktornotor
- BBCoder IV
- Posts: 167
- Joined: 14 Sep 2011, 23:20
- BBCodes: 30
- Favourite MOD: Thanks for Posts
- Contact:
[1.0.2] Views goal percentage messed up when goal reached
Views goal 1000 | Total views 34869 | Remaining -33869 | 3,487% (red bar)
Support requests via PM go straight to /dev/null!
- Stoker
- Site Admin
- Posts: 3558
- Joined: 12 May 2008, 23:26
- BBCodes: 239
- Favourite BBCode: Anipro
- Favourite MOD: PrettyPhoto
- Location: Denmark
- Contact:
[1.0.2] Views goal percentage messed up when goal reached
Hmm, you should have the same files I have: http://easycaptures.com/6824988521
Board rules! No PM support
- doktornotor
- BBCoder IV
- Posts: 167
- Joined: 14 Sep 2011, 23:20
- BBCodes: 30
- Favourite MOD: Thanks for Posts
- Contact:
[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;
Support requests via PM go straight to /dev/null!
- doktornotor
- BBCoder IV
- Posts: 167
- Joined: 14 Sep 2011, 23:20
- BBCodes: 30
- Favourite MOD: Thanks for Posts
- Contact:
[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.
Support requests via PM go straight to /dev/null!
- Stoker
- Site Admin
- Posts: 3558
- Joined: 12 May 2008, 23:26
- BBCodes: 239
- Favourite BBCode: Anipro
- Favourite MOD: PrettyPhoto
- Location: Denmark
- Contact:
[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.
Board rules! No PM support
- doktornotor
- BBCoder IV
- Posts: 167
- Joined: 14 Sep 2011, 23:20
- BBCodes: 30
- Favourite MOD: Thanks for Posts
- Contact:
[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.
Support requests via PM go straight to /dev/null!
- Stoker
- Site Admin
- Posts: 3558
- Joined: 12 May 2008, 23:26
- BBCodes: 239
- Favourite BBCode: Anipro
- Favourite MOD: PrettyPhoto
- Location: Denmark
- Contact:
[1.0.2] Views goal percentage messed up when goal reached
The problem is number format percent:
'FORUM_VIEW_PERCENT' => $forum_goals_views_percent,
Board rules! No PM support
- Stoker
- Site Admin
- Posts: 3558
- Joined: 12 May 2008, 23:26
- BBCodes: 239
- Favourite BBCode: Anipro
- Favourite MOD: PrettyPhoto
- Location: Denmark
- Contact:
[1.0.2] Views goal percentage messed up when goal reached
Please test round:
'FORUM_VIEW_PERCENT' => round($forum_goals_views_percent),
Board rules! No PM support
- doktornotor
- BBCoder IV
- Posts: 167
- Joined: 14 Sep 2011, 23:20
- BBCodes: 30
- Favourite MOD: Thanks for Posts
- Contact:
[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, 15:56, edited 1 time in total.
Support requests via PM go straight to /dev/null!
- Stoker
- Site Admin
- Posts: 3558
- Joined: 12 May 2008, 23:26
- BBCodes: 239
- Favourite BBCode: Anipro
- Favourite MOD: PrettyPhoto
- Location: Denmark
- Contact:
[1.0.2] Views goal percentage messed up when goal reached
You also have to repplace the other instances of number_format with round.
Board rules! No PM support