Skip to content

Commit 4763a8d

Browse files
authored
Merge pull request #1890 from johnhenley/dev98/features/performance-topposts-1889
ENH: Refactor WhatsNew data retrieval and caching logic
2 parents eabd1c6 + 608d188 commit 4763a8d

8 files changed

Lines changed: 263 additions & 143 deletions

File tree

Dnn.CommunityForums/CustomControls/ServerControls/WhatsNewControl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ protected override void OnLoad(EventArgs e)
202202
}
203203
else
204204
{
205-
dr = DataProvider.Instance().GetPosts(this.PortalId, this.ForumIds, this.TopicsOnly, this.RandomOrder, this.Rows, this.Tags, this.FilterByUserId);
205+
dr = DataProvider.Instance().GetPosts(this.ForumIds, this.TopicsOnly, this.RandomOrder, this.Rows, this.Tags, this.FilterByUserId);
206206
}
207207

208208
try

Dnn.CommunityForums/CustomControls/UserControls/WhatsNewRSS.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ namespace DotNetNuke.Modules.ActiveForums.Controls
2222
{
2323
using System;
2424
using System.Collections;
25+
using System.Collections.Generic;
2526
using System.ComponentModel;
2627
using System.Text;
2728
using System.Text.RegularExpressions;
2829
using System.Web;
2930
using System.Web.UI;
3031

3132
using DotNetNuke.Entities.Portals;
33+
using DotNetNuke.Modules.ActiveForums.Data;
34+
35+
using Newtonsoft.Json.Bson;
3236

3337
[DefaultProperty("Text"), ToolboxData("<{0}:WhatsNewRSS runat=server></{0}:WhatsNewRSS>")]
3438
public class WhatsNewRSS : Control
@@ -250,8 +254,8 @@ private string BuildRSS()
250254
// build items
251255
var forumids = this.Settings.RSSIgnoreSecurity ? this.Settings.Forums : this.AuthorizedForums;
252256

253-
var dr = DataProvider.Instance().GetPosts(this.PortalId, forumids, true, false, this.Settings.Rows, this.Settings.Tags);
254257
var sHost = Utilities.GetHost();
258+
var dr = DataProvider.Instance().GetPosts(forums: forumids, topicsOnly: true, randomOrder: false, rows: this.Settings.Rows, tags: this.Settings.Tags);
255259

256260
try
257261
{
@@ -287,16 +291,14 @@ private string BuildRSS()
287291
lastBuildDate = dateCreated;
288292
}
289293

290-
var ts = SettingsBase.GetModuleSettings(topicModuleId);
291-
292294
string url;
293295
if (string.IsNullOrEmpty(sTopicUrl) || !Utilities.UseFriendlyURLs(topicModuleId))
294296
{
295297
string[] @params = { ParamKeys.ViewType + "=" + Views.Topic, ParamKeys.ForumId + "=" + forumId, ParamKeys.TopicId + "=" + topicId };
296298
url = Utilities.NavigateURL(topicTabId, string.Empty, @params);
297299
if (url.IndexOf(HttpContext.Current.Request.Url.Host, StringComparison.CurrentCulture) == -1)
298300
{
299-
url = Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + url;
301+
url = DotNetNuke.Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + url;
300302
}
301303
}
302304
else
@@ -324,7 +326,7 @@ private string BuildRSS()
324326
// Legacy Attachment functionality uses "attachid"
325327
if (bodyHtml.Contains("&#91;IMAGE:"))
326328
{
327-
var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/";
329+
var strHost = DotNetNuke.Common.Globals.AddHTTP(DotNetNuke.Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/";
328330
const string pattern = "(&#91;IMAGE:(.+?)&#93;)";
329331
foreach (Match match in DotNetNuke.Common.Utilities.RegexUtils.GetCachedRegex(pattern).Matches(bodyHtml))
330332
{
@@ -336,7 +338,7 @@ private string BuildRSS()
336338
// Legacy Attachment functionality uses "attachid"
337339
if (bodyHtml.Contains("&#91;THUMBNAIL:"))
338340
{
339-
var strHost = Common.Globals.AddHTTP(Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/";
341+
var strHost = DotNetNuke.Common.Globals.AddHTTP(DotNetNuke.Common.Globals.GetDomainName(HttpContext.Current.Request)) + "/";
340342
const string pattern = "(&#91;THUMBNAIL:(.+?)&#93;)";
341343
foreach (Match match in DotNetNuke.Common.Utilities.RegexUtils.GetCachedRegex(pattern).Matches(bodyHtml))
342344
{
@@ -347,8 +349,8 @@ private string BuildRSS()
347349
}
348350
}
349351

350-
bodyHtml = bodyHtml.Replace("src=\"/Portals", "src=\"" + Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + "/Portals");
351-
bodyHtml = Utilities.ManageImagePath(bodyHtml, new Uri(Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host)));
352+
bodyHtml = bodyHtml.Replace("src=\"/Portals", "src=\"" + DotNetNuke.Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host) + "/Portals");
353+
bodyHtml = Utilities.ManageImagePath(bodyHtml, new Uri(DotNetNuke.Common.Globals.AddHTTP(HttpContext.Current.Request.Url.Host)));
352354

353355
sb.Append(WriteElement("description", bodyHtml, indent + 1));
354356
}

Dnn.CommunityForums/Providers/DataProviders/SqlDataProvider/SqlDataProvider.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -813,10 +813,12 @@ public override IDataReader PortalForums(int PortalId)
813813
return (IDataReader)SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "activeforums_TP_PortalForums", PortalId);
814814
}
815815

816-
public override IDataReader GetPosts(int PortalId, string Forums, bool TopicsOnly, bool RandomOrder, int Rows, string Tags, int FilterByUserId = -1)
816+
[Obsolete("Deprecated in Community Forums. Removed in 10.00.00. Not Used.")]
817+
public override IDataReader GetPosts(int PortalId, string Forums, bool TopicsOnly, bool RandomOrder, int Rows, string Tags, int FilterByUserId = -1) => throw new NotImplementedException();
818+
819+
public override IDataReader GetPosts(string Forums, bool TopicsOnly, bool RandomOrder, int Rows, string Tags, int FilterByUserId = -1)
817820
{
818-
const bool IgnoreSecurity = false; // Required by proc but not currently used
819-
return (IDataReader)SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "activeforums_TP_GetPosts", PortalId, Forums, TopicsOnly, RandomOrder, Rows, IgnoreSecurity, Tags, FilterByUserId);
821+
return (IDataReader)SqlHelper.ExecuteReader(this.ConnectionString, this.DatabaseOwner + this.ObjectQualifier + "activeforums_TP_GetPosts", Forums, TopicsOnly, RandomOrder, Rows, Tags, FilterByUserId);
820822
}
821823

822824
public override IDataReader GetPostsByUser(int PortalId, int Rows, bool IsSuperUser, int currentUserId, int FilteredUserid, bool TopicsOnly, string ForumIds)

0 commit comments

Comments
 (0)