private int CalculateTotalClicks() { var results = ClickedLinkInfoProvider.GetClickedLinks().Source(s => s.Join <LinkInfo>("ClickedLinkNewsletterLinkID", "LinkId")) .WhereIn("LinkIssueID", mParentAndVariantsIDs); return(results.Count); }
/// <summary> /// Total clicks value must not be higher then the count of subscribers. /// </summary> private void GenerateClickedLinksToIssue(int issueId, string linkTarget, int totalClicks, int uniqueClicks, IList <string> subscribersEmails) { var link = new LinkInfo { LinkIssueID = issueId, LinkTarget = linkTarget, LinkDescription = "Try Ethiopian Coffee" }; LinkInfoProvider.SetLinkInfo(link); for (var i = 0; i < totalClicks; i++) { // Simulate non-unique clicks var subscriberIndex = (i <= (totalClicks - uniqueClicks)) ? 0 : i; var clickedLink = new ClickedLinkInfo { ClickedLinkEmail = subscribersEmails[subscriberIndex], ClickedLinkTime = GetRandomDate(DateTime.Now.AddMonths(-1), DateTime.Now.AddDays(-1)), ClickedLinkNewsletterLinkID = link.LinkID, }; ClickedLinkInfoProvider.SetClickedLinkInfo(clickedLink); } }
private void GenerateClickedLinksToIssue( int issueId, string linkTarget, int totalClicks, int uniqueClicks, IList <string> subscribersEmails) { var linkObj = new LinkInfo { LinkIssueID = issueId, LinkTarget = linkTarget, LinkDescription = "Try Ethiopian Coffee" }; LinkInfoProvider.SetLinkInfo(linkObj); for (var index1 = 0; index1 < totalClicks; ++index1) { var index2 = index1 <= totalClicks - uniqueClicks ? 0 : index1; ClickedLinkInfoProvider.SetClickedLinkInfo(new ClickedLinkInfo { ClickedLinkEmail = subscribersEmails[index2], ClickedLinkTime = GetRandomDate(DateTime.Now.AddMonths(-1), DateTime.Now.AddDays(-1.0)), ClickedLinkNewsletterLinkID = linkObj.LinkID }); } }
private int CalculateUniqueClicks() { var results = ClickedLinkInfoProvider.GetClickedLinks().Source(s => s.Join <LinkInfo>("ClickedLinkNewsletterLinkID", "LinkId")) .WhereIn("LinkIssueID", mParentAndVariantsIDs) .Distinct().Columns("ClickedLinkEmail", "LinkIssueID"); return(results.Count); }
protected void Page_Load(object sender, EventArgs e) { mNewsletter = EditedObjectParent as NewsletterInfo; if (mNewsletter == null) { RedirectToAccessDenied(GetString("general.invalidparameters")); } if (!mNewsletter.CheckPermissions(PermissionsEnum.Read, CurrentSiteName, CurrentUser)) { RedirectToAccessDenied(mNewsletter.TypeInfo.ModuleName, "Read"); } mBounceMonitoringEnabled = NewsletterHelper.MonitorBouncedEmails(CurrentSiteName); mTrackingEnabled = NewsletterHelper.IsTrackingAvailable(); if (mTrackingEnabled && !mBounceMonitoringEnabled) { ShowInformation(GetString("newsletter.viewadditionalstatsmessage")); } ScriptHelper.RegisterTooltip(this); // Initialize unigrid UniGrid.WhereCondition = String.Format("IssueNewsletterID={0} AND IssueVariantOfIssueID IS NULL", mNewsletter.NewsletterID); UniGrid.ZeroRowsText = GetString("Newsletter_Issue_List.NoIssuesFound"); UniGrid.OnAction += uniGrid_OnAction; UniGrid.OnBeforeDataReload += UniGrid_OnBeforeDataReload; UniGrid.OnExternalDataBound += UniGrid_OnExternalDataBound; // Initialize header actions InitHeaderActions(); // Prepare data for listing // Group clicked link records by IssueID with Columns LinkIssueID, UniqueUserClicks, VariantParent (to calculate clicked links through all variant) mClickedLinksSummary = ClickedLinkInfoProvider.GetClickedLinks() .Columns(new QueryColumn("LinkIssueID"), new AggregatedColumn(AggregationType.Count, "DISTINCT(ClickedLinkEmail)").As("UniqueUserClicks")) .Source(s => s.Join <LinkInfo>("ClickedLinkNewsletterLinkID", "LinkID")) .GroupBy("LinkIssueID"); // Prepare variant summaries mVariantIssueSummaries = IssueInfoProvider.GetIssues() .Columns(new QueryColumn("IssueVariantOfIssueID"), new AggregatedColumn(AggregationType.Sum, "IssueOpenedEmails").As("OpenedEmailsSum")) .WhereEquals("IssueNewsletterID", mNewsletter.NewsletterID) .GroupBy("IssueVariantOfIssueID") .Having("IssueVariantOfIssueID IS NOT NULL"); // AB Variant issues for current newsletter mVariantIssues = IssueInfoProvider.GetIssues() .Columns("IssueID", "IssueVariantOfIssueID") .WhereEquals("IssueNewsletterID", mNewsletter.NewsletterID) .WhereNotNull("IssueVariantOfIssueID"); AddBrokenEmailUrlNotifier(mNewsletter, lblUrlWarning); }
protected void Page_Load(object sender, EventArgs e) { PageTitle.TitleText = GetString("newsletter_issue_subscribersclicks.title"); linkId = QueryHelper.GetInteger("linkid", 0); if (linkId == 0) { RequestHelper.EndResponse(); } LinkInfo link = LinkInfoProvider.GetLinkInfo(linkId); EditedObject = link; IssueInfo issue = IssueInfoProvider.GetIssueInfo(link.LinkIssueID); EditedObject = issue; // Prevent accessing issues from sites other than current site if (issue.IssueSiteID != SiteContext.CurrentSiteID) { RedirectToResourceNotAvailableOnSite("Issue with ID " + link.LinkIssueID); } var listingWhereCondition = new WhereCondition().WhereEquals("ClickedLinkNewsletterLinkID", linkId); // Link's issue is the main A/B test issue if (issue.IssueIsABTest && !issue.IssueIsVariant) { // Get A/B test and its winner issue ID ABTestInfo test = ABTestInfoProvider.GetABTestInfoForIssue(issue.IssueID); if (test != null) { // Get ID of the same link from winner issue var winnerLink = LinkInfoProvider.GetLinks() .WhereEquals("LinkIssueID", test.TestWinnerIssueID) .WhereEquals("LinkTarget", link.LinkTarget) .WhereEquals("LinkDescription", link.LinkDescription) .TopN(1) .Column("LinkID") .FirstOrDefault(); if (winnerLink != null) { if (winnerLink.LinkID > 0) { // Add link ID of winner issue link listingWhereCondition.Or(new WhereCondition().WhereEquals("ClickedLinkNewsletterLinkID", winnerLink.LinkID)); } } } } UniGrid.Pager.DefaultPageSize = PAGESIZE; UniGrid.Pager.ShowPageSize = false; UniGrid.FilterLimit = 1; fltOpenedBy.EmailColumn = "ClickedLinkEmail"; // Get click count by email UniGrid.DataSource = ClickedLinkInfoProvider.GetClickedLinks() .Columns( new QueryColumn("ClickedLinkEmail"), new AggregatedColumn(AggregationType.Count, null).As("ClickCount") ) .GroupBy("ClickedLinkEmail") .Where(listingWhereCondition) .And() .Where(fltOpenedBy.WhereCondition) .OrderByDescending("ClickCount") .Result; }