Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions Doppler.ReportingApi/Infrastructure/CampaignRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,15 @@ FROM dbo.usertimezone timezone
DATEADD(MINUTE, @timezone, C.[UTCSentDate])
AS DATE
) AS [Date]
,COALESCE(C.[AmountSentSubscribers], C.[AmountSubscribersToSend], 0) AS [Sent]
,ISNULL(C.[DistinctOpenedMailCount],0) [Opens]
,ISNULL(C.[DistinctClickCount],0) [Clicks]
,ISNULL(C.[HardBouncedMailCount],0) [Hard]
,ISNULL (C.[SoftBouncedMailCount],0) [Soft]
,(CASE C.[Status]
WHEN 9
THEN ISNULL(C.[UnsubscriptionsCount],0)
ELSE 0
END) [Unsubscribes]
,COALESCE(CS.[AmountSentSubscribers], CS.[AmountSubscribersToSend], 0) AS [Sent]
,ISNULL(CS.[DistinctOpenedMailCount],0) [Opens]
,ISNULL(CS.[DistinctClickCount],0) [Clicks]
,ISNULL(CS.[HardBouncedMailCount],0) [Hard]
,ISNULL (CS.[SoftBouncedMailCount],0) [Soft]
,ISNULL(CS.[UnsubscriptionsCount],0) [Unsubscribes]
,0 [Spam]
FROM [dbo].[Campaign] C WITH (NOLOCK)
LEFT JOIN dbo.CampaignStats CS ON CS.IdCampaign = C.IdCampaign
JOIN [dbo].[User] U WITH (NOLOCK)
ON C.[IdUser] = U.[IdUser]
WHERE
Expand Down
7 changes: 4 additions & 3 deletions Doppler.ReportingApi/Infrastructure/SummaryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ public async Task<CampaignsSummary> GetCampaignsSummaryByUserAsync(string userNa
CAST(NULLIF((ISNULL(T.DistinctOpenedMailCount, 0) + ISNULL(T.UnopenedMailCount, 0)), 0) AS FLOAT) * 100 AS ClickThroughRate
FROM (
SELECT
SUM(Campaign.AmountSentSubscribers) AS TotalSentEmails,
SUM(Campaign.DistinctOpenedMailCount) AS DistinctOpenedMailCount,
SUM(CS.AmountSentSubscribers) AS TotalSentEmails,
SUM(CS.DistinctOpenedMailCount) AS DistinctOpenedMailCount,

SUM(Campaign.UnopenedMailCount) AS UnopenedMailCount,
SUM(CS.UnopenedMailCount) AS UnopenedMailCount,
SUM(LinkInfo.UniqueClickCount) AS UniqueClickCount
FROM [user]
INNER JOIN Campaign WITH (NOLOCK) on [user].iduser = Campaign.IdUser
LEFT JOIN CampaignStats CS ON CS.IdCampaign = Campaign.IdCampaign
OUTER APPLY (
SELECT COUNT(DISTINCT LT.IdSubscriber) AS UniqueClickCount
FROM Link L WITH (NOLOCK)
Expand Down
Loading