YAFLogo

airsickmoth
  • airsickmoth
  • 86% (Honored)
  • YAF Forumling Topic Starter
15 years ago
I was trying to get MaxUsers to function on my server when I noticed that the value is retrieved out of the BoadSettings context.

The problem here is that as long as the server never resets, the BoardSettings stay the same, until they are manually changed by saving them in the Host Settings.

What I was thinking was to include MaxUsers and MaxUsersWhen as values passed back by yaf_board_poststats stored procedure.


BEGIN
	SELECT
		Posts = (select count(1) from [dbo].[yaf_Message] a join [dbo].[yaf_Topic] b on b.TopicID=a.TopicID join [dbo].[yaf_Forum] c on c.ForumID=b.ForumID join [dbo].[yaf_Category] d on d.CategoryID=c.CategoryID where d.BoardID=@BoardID AND (a.Flags & 24)=16),
		Topics = (select count(1) from [dbo].[yaf_Topic] a join [dbo].[yaf_Forum] b on b.ForumID=a.ForumID join [dbo].[yaf_Category] c on c.CategoryID=b.CategoryID where c.BoardID=@BoardID AND (a.Flags & 😎 <> 😎,
		Forums = (select count(1) from [dbo].[yaf_Forum] a join [dbo].[yaf_Category] b on b.CategoryID=a.CategoryID where b.BoardID=@BoardID),
		Members = (select count(1) from [dbo].[yaf_User] a where a.BoardID=@BoardID AND (Flags & 2) = 2 AND (a.Flags & 4) = 0),
		MaxUsers = (SELECT [Value] FROM [dbo].[yaf_Registry] WHERE LOWER(Name) = LOWER('maxusers') and BoardID=@BoardID),
		MaxUsersWhen = (SELECT [Value] FROM [dbo].[yaf_Registry] WHERE LOWER(Name) = LOWER('maxuserswhen') and BoardID=@BoardID),
		LastPostInfo.*,
		LastMemberInfo.*
	FROM .....

Then in the ForumStatistics Control


if (!statisticsDataRow.IsNull("MaxUsers"))
	MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), statisticsDataRow["MaxUsers"], YafDateTime.FormatDateTimeTopic(statisticsDataRow["MaxUsersWhen"]));
else
	MostUsersCount.Text = String.Format(PageContext.Localization.GetText("MAX_ONLINE"), activeStats["ActiveUsers"], YafDateTime.FormatDateTimeTopic(DateTime.Now));

This way the MaxUser stats are loaded with the other statistics and saved in the cache with them and fall under their expiry.

The only problem encountered so far is that if you add the above code to the control after your server has been already running, then the cache needs to be reset otherwise there won't be a "MaxUsers" field in the row. I added the IsNull in case it doesn't come back with values, then at least it will show the current number of users instead of just 1.
Sponsor

Jaben
  • Jaben
  • 100% (Exalted)
  • YAF Developer
15 years ago
Done. Committed... Thanks ASM.
mpalinski
15 years ago
I've already added yaf_active_updatemaxstats stored procedure and modified my yaf_pageload as well.

It works well, and the table, yaf_Registry: (Registry_ID: 50 / Name: maxusers / Value: 7 / BoardID: 1) exists,
but since the cache exists without an IIS reset, it still shows up as:
"Most users ever online was 3, Yesterday at 4:48:55 PM."

Is there a quick-fix some of us can integrate into our stable 1.9.1.7/8 versions?
YAF Logo Copyright © YetAnotherForum.NET & Ingo Herbote. All rights reserved
About Us

The YAF.NET is an open source .NET forum project. YAF.NET is supported by an team of international developers who are build community by building community software.

Powered by Resharper Donate with PayPal button