Page 1 of 1

Top Stats ignoring Global Announcements

Posted: 25 Jul 2012, 18:56
by dazbobaby
I've noticed that Top Stats isn't updating properly:
Image1.jpg
Image2.jpg

Top Stats ignoring Global Announcements

Posted: 26 Jul 2012, 08:50
by Stoker
This code is from the un-released version:

Code: Select all

// Most viewed topics
if (!empty($config['tsmvt_enable']) && sizeof($flist))
{
	$sql = 'SELECT topic_id, forum_id, topic_title, topic_views, topic_time, topic_first_poster_name, topic_first_poster_colour, topic_poster, topic_last_poster_id
		FROM ' . TOPICS_TABLE . ' 
		WHERE ' . $db->sql_in_set('forum_id', $flist) . '
		ORDER BY topic_views DESC';
	$result = $db->sql_query_limit($sql, $config['tsmvt_number']);
	
	while ($row = $db->sql_fetchrow($result))
	{
		$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']);
		$view_first_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_poster']);
		$view_last_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_last_poster_id']);
		
		$template->assign_block_vars('most_viewed', array(
			'TOPIC_ID'						=> $row['topic_id'], 
			'FORUM_ID'	    				=> $row['forum_id'],
			'TOPIC_TITLE'					=> $row['topic_title'],
			'TOPIC_VIEWS'					=> $row['topic_views'],
			'TOPIC_TIME'                    => $user->format_date($row['topic_time']), 
			'TOPIC_FIRST_POSTER_NAME'		=> $row['topic_first_poster_name'],
			'TOPIC_FIRST_POSTER_COLOUR'		=> $row['topic_first_poster_colour'],
			'U_FIRST_TOPIC'					=> $view_topic_url,
			'USERNAME_FIRST'				=> $view_first_poster,
			'USERNAME_LAST'					=> $view_last_poster,
		));
	}
	$db->sql_freeresult($result);
	
	$template->assign_vars(array(
		'S_TSMVT_ENABLE'      			=> $config['tsmvt_enable'],
		'TSMVT_NUMBER'					=> $config['tsmvt_number'],
    ));
}
	
// Most replied topics
if (!empty($config['tsmrt_enable']) && sizeof($flist))
{
	$sql = 'SELECT topic_id, forum_id, topic_title, topic_replies, topic_time, topic_first_poster_name, topic_first_poster_colour, topic_poster, topic_last_poster_id 
		FROM ' . TOPICS_TABLE . ' 
		WHERE ' . $db->sql_in_set('forum_id', $flist) . '
		ORDER BY topic_replies DESC';
	$result = $db->sql_query_limit($sql, $config['tsmrt_number']);
	
	while ($row = $db->sql_fetchrow($result))
	{
		$view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . '&t=' . $row['topic_id']);
		$view_first_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_poster']);
		$view_last_poster = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile' . '&u=' . $row['topic_last_poster_id']);
		
		$template->assign_block_vars('most_replied', array(
			'TOPIC_ID'						=> $row['topic_id'], 
			'FORUM_ID'	    				=> $row['forum_id'],
			'TOPIC_TITLE'					=> $row['topic_title'],
			'TOPIC_REPLIES'					=> $row['topic_replies'],
			'TOPIC_TIME'                    => $user->format_date($row['topic_time']), 
			'TOPIC_FIRST_POSTER_NAME'		=> $row['topic_first_poster_name'],
			'TOPIC_FIRST_POSTER_COLOUR'		=> $row['topic_first_poster_colour'],
			'U_FIRST_TOPIC'					=> $view_topic_url,
			'USERNAME_FIRST'				=> $view_first_poster,
			'USERNAME_LAST'					=> $view_last_poster,
		));
	}
	$db->sql_freeresult($result);
	
	$template->assign_vars(array(
		'S_TSMRT_ENABLE'      			=> $config['tsmrt_enable'],
		'TSMRT_NUMBER'					=> $config['tsmrt_number'],
    ));
}
Should work with global announcements.

Top Stats ignoring Global Announcements

Posted: 26 Jul 2012, 10:15
by dazbobaby
Which file is this from Stoker?

got it, functions_top_stats.php

Top Stats ignoring Global Announcements

Posted: 26 Jul 2012, 10:21
by Stoker
yes, the most viewed and most replied part of it.