<commit_before>/* Yet Another Forum.NET
 * Copyright (C) 2006-2009 <NAME>
 * http://www.yetanotherforum.net/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
namespace YAF.Controls
{
  using System;
  using System.Data;
  using System.Text;
  using YAF.Classes;
  using YAF.Classes.Core;
  using YAF.Classes.Data;
  using YAF.Classes.UI;
  using YAF.Classes.Utils;

  /// <summary>
  /// The forum statistics.
  /// </summary>
  public partial class ForumStatistics : BaseUserControl
  {
    /// <summary>
    /// Initializes a new instance of the <see cref="ForumStatistics"/> class.
    /// </summary>
    public ForumStatistics()
    {
      Load += new EventHandler(ForumStatistics_Load);
    }

    /// <summary>
    /// The forum statistics_ load.
    /// </summary>
    /// <param name="sender">
    /// The sender.
    /// </param>
    /// <param name="e">
    /// The e.
    /// </param>
    private void ForumStatistics_Load(object sender, EventArgs e)
    {
      // Active users
      // Call this before forum_stats to clean up active users'
      DataTable dt = DB.active_list(PageContext.PageBoardID, null, PageContext.BoardSettings.ActiveListTime, PageContext.BoardSettings.UseStyledNicks);
      if (YafContext.Current.BoardSettings.UseStyledNicks)
      {
        StyleHelper.DecodeStyleByTable(ref dt);
      }

      this.ActiveUsers1.ActiveUserTable = dt;

      var au = new ActiveUsers();

      // "Active Users" Count and Most Users Count
      DataRow activeStats = DB.active_stats(PageContext.PageBoardID);

      this.ActiveUserCount.Text = FormatActiveUsers(activeStats);

      // Forum Statistics
        DataRow dr = DB.board_poststats(PageContext.PageBoardID);
      // Set colorOnly parameter to false, as we get here color from data field in the place
      if ( PageContext.BoardSettings.UseStyledNicks )
          dr["LastUserStyle"] =  YAF.Classes.UI.StyleHelper.DecodeStyleByString(dr["LastUserStyle"].ToString(), false);
      else
          dr["LastUserStyle"] = null;
      string key = YafCache.GetBoardCacheKey(Constants.Cache.BoardStats);
      var statisticsDataRow = PageContext.Cache.GetItem<DataRow>(
        key, PageContext.BoardSettings.ForumStatisticsCacheTimeout, () => dr);

      // show max users...
      if (!statisticsDataRow.IsNull("MaxUsers"))
      {
        this.MostUsersCount.Text = PageContext.Localization.GetTextFormatted(
          "MAX_ONLINE", statisticsDataRow["MaxUsers"], YafServices.DateTime.FormatDateTimeTopic(statisticsDataRow["MaxUsersWhen"]));
      }
      else<commit_msg>Was wondering why the front page was so slow... because the board stats caching was taking out. Also added Active User caching.<commit_after>/* Yet Another Forum.NET
 * Copyright (C) 2006-2009 <NAME>
 * http://www.yetanotherforum.net/
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
namespace YAF.Controls
{
  using System;
  using System.Data;
  using System.Text;
  using YAF.Classes;
  using YAF.Classes.Core;
  using YAF.Classes.Data;
  using YAF.Classes.UI;
  using YAF.Classes.Utils;

  /// <summary>
  /// The forum statistics.
  /// </summary>
  public partial class ForumStatistics : BaseUserControl
  {
    /// <summary>
    /// Initializes a new instance of the <see cref="ForumStatistics"/> class.
    /// </summary>
    public ForumStatistics()
    {
      Load += ForumStatistics_Load;
    }

    /// <summary>
    /// The forum statistics_ load.
    /// </summary>
    /// <param name="sender">
    /// The sender.
    /// </param>
    /// <param name="e">
    /// The e.
    /// </param>
    private void ForumStatistics_Load(object sender, EventArgs e)
    {
      // Active users : Call this before forum_stats to clean up active users
      string key = YafCache.GetBoardCacheKey(Constants.Cache.UsersOnlineStatus);
      DataTable activeUsers = PageContext.Cache.GetItem(
        key,
        (double) YafContext.Current.BoardSettings.OnlineStatusCacheTimeout,
        () =>
        {
          DataTable au = DB.active_list(
            YafContext.Current.PageBoardID, false, YafContext.Current.BoardSettings.ActiveListTime, PageContext.BoardSettings.UseStyledNicks);
          if (PageContext.BoardSettings.UseStyledNicks)
          {
            StyleHelper.DecodeStyleByTable(ref au);
          }
          return au;
        });

      this.ActiveUsers1.ActiveUserTable = activeUsers;

      // "Active Users" Count and Most Users Count
      DataRow activeStats = DB.active_stats(PageContext.PageBoardID);
      this.ActiveUserCount.Text = FormatActiveUsers(activeStats);

      // Forum Statistics
      key = YafCache.GetBoardCacheKey(Constants.Cache.BoardStats);
      var statisticsDataRow = PageContext.Cache.GetItem(
        key,
        PageContext.BoardSettings.ForumStatisticsCacheTimeout,
        () =>
        {
          // get the post stats
          DataRow dr = DB.board_poststats(PageContext.PageBoardID);

          // Set colorOnly parameter to false, as we get here color from data field in the place
          dr["LastUserStyle"] = this.PageContext.BoardSettings.UseStyledNicks ? StyleHelper.DecodeStyleByString(dr["LastUserStyle"].ToString(), false) : null;
          return dr;
        });

      // show max users...
      if (!statisticsDataRow.IsNull("MaxUsers"))
      {
        this.MostUsersCount.Text = PageContext.Localization.GetTextFormatted(
          "MAX_ONLINE", statisticsDataRow["MaxUsers"], YafServices.DateTime.FormatDateTimeTopic(statisticsDataRow["MaxUsersWhen"]));
      }
      else
{'fraction_non_alphanumeric': 0.10085993295437982, 'fraction_numerical': 0.006996064713598601, 'mean_word_length': 2.8702763677382968, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6645387', 'n_tokens_mistral': 1926, 'n_tokens_neox': 1854, 'n_words': 580}