Skip to content

Commit 978d433

Browse files
authored
Merge pull request #110 from FromDoppler/doi-2682-use-utc-sent-date
[DOI-2682] Use UTCSentDate instead of UTCScheduleDate
2 parents dbfb134 + 2854a13 commit 978d433

2 files changed

Lines changed: 32 additions & 32 deletions

File tree

Doppler.ReportingApi/Infrastructure/CampaignRepository.cs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ FROM dbo.usertimezone timezone
4242
C.[IdUser]
4343
,[IdCampaign]
4444
,CAST(
45-
DATEADD(MINUTE, @timezone, C.[UTCScheduleDate])
45+
DATEADD(MINUTE, @timezone, C.[UTCSentDate])
4646
AS DATE
4747
) AS [Date]
4848
,COALESCE(C.[AmountSentSubscribers], C.[AmountSubscribersToSend], 0) AS [Sent]
@@ -62,7 +62,7 @@ JOIN [dbo].[User] U WITH (NOLOCK)
6262
WHERE
6363
U.[Email] = @userName
6464
AND C.[Status] IN (5,9,10)
65-
AND C.[UTCScheduleDate] BETWEEN @startDate AND @endDate
65+
AND C.[UTCSentDate] BETWEEN @startDate AND @endDate
6666
AND C.[IdTestCampaign] IS NULL
6767
AND C.[IdScheduledTask] IS NULL
6868
AND C.Active = 1
@@ -71,7 +71,7 @@ UNION ALL
7171
S.[IdUser]
7272
,S.[IdCampaign]
7373
,CAST(
74-
DATEADD(MINUTE, @timezone, C.[UTCScheduleDate])
74+
DATEADD(MINUTE, @timezone, C.[UTCSentDate])
7575
AS DATE
7676
) AS [Date]
7777
,0 [Sent]
@@ -101,7 +101,7 @@ JOIN [dbo].[User] U WITH (NOLOCK)
101101
WHERE
102102
U.[Email] = @userName
103103
AND C.[Status] IN (5,9,10)
104-
AND C.[UTCScheduleDate] BETWEEN @startDate AND @endDate
104+
AND C.[UTCSentDate] BETWEEN @startDate AND @endDate
105105
AND S.[IdSubscribersStatus] = 5
106106
AND C.[IdTestCampaign] IS NULL
107107
AND C.[IdScheduledTask] IS NULL
@@ -110,7 +110,7 @@ GROUP BY
110110
S.[IdUser]
111111
,S.[IdCampaign]
112112
,CAST(
113-
DATEADD(MINUTE, @timezone, C.[UTCScheduleDate])
113+
DATEADD(MINUTE, @timezone, C.[UTCSentDate])
114114
AS DATE
115115
)
116116
) AS RPT
@@ -145,7 +145,7 @@ FROM dbo.usertimezone timezone
145145
RPT.[IdUser]
146146
,RPT.[IdCampaign]
147147
,RPT.[Name]
148-
,dateadd(MINUTE, @timezone, RPT.[UTCScheduleDate]) AS [UTCScheduleDate]
148+
,dateadd(MINUTE, @timezone, RPT.[UTCSentDate]) AS [UTCSentDate]
149149
,RPT.[FromEmail]
150150
,RPT.[CampaignType]
151151
,RPT.[IdTestAB]
@@ -192,7 +192,7 @@ END AS [SpamRate]
192192
C.[IdUser]
193193
,C.[IdCampaign]
194194
,C.[Name]
195-
,C.[UTCScheduleDate]
195+
,C.[UTCSentDate]
196196
,C.[FromEmail]
197197
,C.[CampaignType]
198198
,C.[IdTestAB]
@@ -243,8 +243,8 @@ GROUP BY c.IdCampaign
243243
U.[Email] = @userName
244244
AND C.[Status] IN (5,9)
245245
AND C.Active = 1
246-
AND (@startDate IS NULL OR C.[UTCScheduleDate] >= @startDate)
247-
AND (@endDate IS NULL OR C.[UTCScheduleDate] < @endDate)
246+
AND (@startDate IS NULL OR C.[UTCSentDate] >= @startDate)
247+
AND (@endDate IS NULL OR C.[UTCSentDate] < @endDate)
248248
AND (@campaignName IS NULL OR LOWER(LTRIM(RTRIM(C.[Name]))) LIKE '%' + LOWER(LTRIM(RTRIM(@campaignName))) + '%')
249249
AND (
250250
@campaignType IS NULL
@@ -264,13 +264,13 @@ OR C.[IdLabel] IN @labels
264264
GROUP BY RPT.[IdUser]
265265
,RPT.[IdCampaign]
266266
,RPT.[Name]
267-
,RPT.[UTCScheduleDate]
267+
,RPT.[UTCSentDate]
268268
,RPT.[FromEmail]
269269
,RPT.[CampaignType]
270270
,RPT.[IdTestAB]
271271
,RPT.[LabelName]
272272
,RPT.[LabelColour]
273-
ORDER BY RPT.[UTCScheduleDate] DESC
273+
ORDER BY RPT.[UTCSentDate] DESC
274274
OFFSET @pageNumber * @pageSize ROWS
275275
FETCH NEXT @pageSize ROWS ONLY";
276276

@@ -297,8 +297,8 @@ LEFT JOIN [dbo].[Label] L WITH (NOLOCK)
297297
U.[Email] = @userName
298298
AND C.[Status] IN (5,9)
299299
AND C.Active = 1
300-
AND (@startDate IS NULL OR C.[UTCScheduleDate] >= @startDate)
301-
AND (@endDate IS NULL OR C.[UTCScheduleDate] < @endDate)
300+
AND (@startDate IS NULL OR C.[UTCSentDate] >= @startDate)
301+
AND (@endDate IS NULL OR C.[UTCSentDate] < @endDate)
302302
AND (@campaignName IS NULL OR LOWER(LTRIM(RTRIM(C.[Name]))) LIKE '%' + LOWER(LTRIM(RTRIM(@campaignName))) + '%')
303303
AND (
304304
@campaignType IS NULL
@@ -335,8 +335,8 @@ FROM dbo.usertimezone timezone
335335
336336
SELECT
337337
RPT.[IdUser]
338-
,YEAR(dateadd(MINUTE, @timezone, UTCScheduleDate)) [Year]
339-
,MONTH(dateadd(MINUTE, @timezone, UTCScheduleDate)) [Month]
338+
,YEAR(dateadd(MINUTE, @timezone, UTCSentDate)) [Year]
339+
,MONTH(dateadd(MINUTE, @timezone, UTCSentDate)) [Month]
340340
,COUNT(DISTINCT RPT.[IdCampaign]) [CampaginsCount]
341341
,SUM(RPT.[Subscribers]) [Subscribers]
342342
,SUM(RPT.[Sent]) [Sent]
@@ -378,7 +378,7 @@ END AS [SpamRate]
378378
SELECT
379379
C.[IdUser]
380380
,C.[IdCampaign]
381-
,C.[UTCScheduleDate]
381+
,C.[UTCSentDate]
382382
,ISNULL(C.[AmountSentSubscribers],0) [Subscribers]
383383
,(ISNULL(C.AmountSentSubscribers, 0) - (ISNULL(C.HardBouncedMailCount, 0) + ISNULL(C.SoftBouncedMailCount, 0))) AS [Sent]
384384
,ISNULL(C.[DistinctOpenedMailCount],0) [Opens]
@@ -395,16 +395,16 @@ JOIN [dbo].[User] U WITH (NOLOCK)
395395
U.[Email] = @userName
396396
AND C.[Status] IN (5,9)
397397
AND C.Active = 1
398-
AND (@startDate IS NULL OR C.[UTCScheduleDate] >= @startDate)
399-
AND (@endDate IS NULL OR C.[UTCScheduleDate] < @endDate)
398+
AND (@startDate IS NULL OR C.[UTCSentDate] >= @startDate)
399+
AND (@endDate IS NULL OR C.[UTCSentDate] < @endDate)
400400
AND C.[IdTestCampaign] IS NULL
401401
AND C.[IdScheduledTask] IS NULL
402402
AND (C.TestABCategory IS NULL OR C.TestABCategory = 3)
403403
UNION ALL
404404
SELECT
405405
S.[IdUser]
406406
,S.[IdCampaign]
407-
,C.[UTCScheduleDate]
407+
,C.[UTCSentDate]
408408
,0 [Subscribers]
409409
,0 [Sent]
410410
,0 [Opens]
@@ -435,8 +435,8 @@ JOIN [dbo].[User] U WITH (NOLOCK)
435435
U.[Email] = @userName
436436
AND C.[Status] IN (5,9)
437437
AND C.Active = 1
438-
AND (@startDate IS NULL OR C.[UTCScheduleDate] >= @startDate)
439-
AND (@endDate IS NULL OR C.[UTCScheduleDate] < @endDate)
438+
AND (@startDate IS NULL OR C.[UTCSentDate] >= @startDate)
439+
AND (@endDate IS NULL OR C.[UTCSentDate] < @endDate)
440440
AND C.[IdTestCampaign] IS NULL
441441
AND C.[IdScheduledTask] IS NULL
442442
AND (C.TestABCategory IS NULL OR C.TestABCategory = 3)
@@ -445,13 +445,13 @@ GROUP BY
445445
S.[IdUser]
446446
,S.[IdCampaign]
447447
,C.[Name]
448-
,C.[UTCScheduleDate]
448+
,C.[UTCSentDate]
449449
,C.[FromEmail]
450450
,C.[CampaignType]
451451
) RPT
452452
GROUP BY RPT.[IdUser]
453-
,YEAR(dateadd(MINUTE, @timezone, UTCScheduleDate))
454-
,MONTH(dateadd(MINUTE, @timezone, UTCScheduleDate))
453+
,YEAR(dateadd(MINUTE, @timezone, UTCSentDate))
454+
,MONTH(dateadd(MINUTE, @timezone, UTCSentDate))
455455
456456
ORDER BY [Year] DESC, [Month] DESC
457457
OFFSET @pageNumber * @pageSize ROWS
@@ -472,24 +472,24 @@ SELECT COUNT(*)
472472
FROM (
473473
SELECT
474474
C.[IdUser],
475-
YEAR(C.[UTCScheduleDate]) AS [Year],
476-
MONTH(C.[UTCScheduleDate]) AS [Month]
475+
YEAR(C.[UTCSentDate]) AS [Year],
476+
MONTH(C.[UTCSentDate]) AS [Month]
477477
FROM [dbo].[Campaign] C WITH (NOLOCK)
478478
JOIN [dbo].[User] U WITH (NOLOCK)
479479
ON C.[IdUser] = U.[IdUser]
480480
WHERE
481481
U.[Email] = @userName
482482
AND C.[Status] IN (5,9)
483483
AND C.Active = 1
484-
AND (@startDate IS NULL OR C.[UTCScheduleDate] >= @startDate)
485-
AND (@endDate IS NULL OR C.[UTCScheduleDate] < @endDate)
484+
AND (@startDate IS NULL OR C.[UTCSentDate] >= @startDate)
485+
AND (@endDate IS NULL OR C.[UTCSentDate] < @endDate)
486486
AND C.[IdTestCampaign] IS NULL
487487
AND C.[IdScheduledTask] IS NULL
488488
AND (C.TestABCategory IS NULL OR C.TestABCategory = 3)
489489
GROUP BY
490490
C.[IdUser],
491-
YEAR(C.[UTCScheduleDate]),
492-
MONTH(C.[UTCScheduleDate])
491+
YEAR(C.[UTCSentDate]),
492+
MONTH(C.[UTCSentDate])
493493
) AS MonthlyGroups;";
494494

495495
var count = await connection.QuerySingleAsync<int>(dummyDatabaseQuery, new { userName, startDate, endDate });

Doppler.ReportingApi/Models/SentCampaignsMetrics.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ public class SentCampaignMetrics
2020
public string Name { get; set; }
2121

2222
/// <summary>
23-
/// UTC date and time when the campaign was scheduled to be sent.
23+
/// UTC date and time when the campaign was sent.
2424
/// </summary>
25-
public DateTime UTCScheduleDate { get; set; }
25+
public DateTime UTCSentDate { get; set; }
2626

2727
/// <summary>
2828
/// Email address used as the sender of the campaign.

0 commit comments

Comments
 (0)