Skip to content

Commit

Permalink
Merge branch 'release/0.64.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Mar 6, 2020
2 parents fb2b786 + e8b5e7a commit 4a8e678
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 29 deletions.
38 changes: 26 additions & 12 deletions GitReleaseManager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,38 @@ create:
footer-content: You can download this release from [nuget.org](https://www.nuget.org/packages/StrongGrid/{milestone})
footer-includes-milestone: true
milestone-replace-text: '{milestone}'
close:
use-issue-comments: true
issue-comment: |-
:tada: This issue has been resolved in version {milestone} :tada:
The release is available on:
- [GitHub Release](https://github.com/{owner}/{repository}/releases/tag/{milestone})
- [NuGet Package](https://www.nuget.org/packages/StrongGrid/{milestone})
Your **[GitReleaseManager](https://github.com/GitTools/GitReleaseManager)** bot :package::rocket:
export:
include-created-date-in-title: true
created-date-string-format: MMMM dd, yyyy
perform-regex-removal: true
regex-text: '### Where to get it(\r\n)*You can .*\)'
multiline-regex: true
issue-labels-include:
- Breaking Change
- Bug
- New Feature
- Improvement
- Documentation
- Breaking Change
- Bug
- New Feature
- Improvement
- Documentation
- Security
issue-labels-exclude:
- Question
- Duplicate
- Invalid
- Wontfix
- Question
- Duplicate
- Invalid
- Wontfix
- Build
- Internal Refactoring
issue-labels-alias:
- name: Documentation
header: Documentation
plural: Documentation
- name: Documentation
header: Documentation
plural: Documentation
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Logzio.DotNet.NLog" Version="1.0.7" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.0" />
<PackageReference Include="Logzio.DotNet.NLog" Version="1.0.9" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.2" />
</ItemGroup>

<ItemGroup>
Expand Down
49 changes: 39 additions & 10 deletions Source/StrongGrid.IntegrationTests/Tests/Statistics.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using StrongGrid.Models;
using StrongGrid.Utilities;
using System;
using System.IO;
using System.Threading;
Expand All @@ -16,10 +17,16 @@ public async Task RunAsync(IClient client, TextWriter log, CancellationToken can
// You get a cryptic error: "unable to get stats"
// I contacted SendGrid support on October 19 2016 (http://support.sendgrid.com/hc/requests/780001)
// and I was told:
// "the issue here is that we expect there to be 52 weeks per year, but that isn't always
// the case and is 'borking' on those first few days as a result of that"
// The workaround is to start on January 4th.
var startDate = new DateTime(DateTime.UtcNow.Year, 1, 4);
// "the issue here is that we expect there to be 52 weeks per year, but that isn't always
// the case and is 'borking' on those first few days as a result of that"
// UPDATE February 2020:
// I confirm that the issue is still present and hasn't been fixed by SendGrid.
// The previous workaround (which was to set the start date on January 4th instead
// of January 1st) worked in 2016 but does not work in 2020. Therefore I'm restoring
// January 1st as the start date and surrounding the 'GetStatistics' in try...catch
// to avoid any problem in the future.

var startDate = new DateTime(DateTime.UtcNow.Year, 1, 1);
var endDate = new DateTime(startDate.Year, 12, 31);

//----- Global Stats -----
Expand All @@ -29,8 +36,15 @@ public async Task RunAsync(IClient client, TextWriter log, CancellationToken can
globalStats = await client.Statistics.GetGlobalStatisticsAsync(startDate, endDate, AggregateBy.Day, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of GLOBAL stats in {startDate.Year} and aggregated by day: {globalStats.Length}").ConfigureAwait(false);

globalStats = await client.Statistics.GetGlobalStatisticsAsync(startDate, endDate, AggregateBy.Week, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of GLOBAL stats in {startDate.Year} and aggregated by week: {globalStats.Length}").ConfigureAwait(false);
try
{
globalStats = await client.Statistics.GetGlobalStatisticsAsync(startDate, endDate, AggregateBy.Week, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of GLOBAL stats in {startDate.Year} and aggregated by week: {globalStats.Length}").ConfigureAwait(false);
}
catch (SendGridException e) when (e.Message.Equals("unable to get stats", StringComparison.OrdinalIgnoreCase))
{
await log.WriteLineAsync($"The SendGrid API returned an exception: '{e.Message}'. Typically, this indicates that there is more than 52 weeks in the current year which is a situation that SendGrid can't handle when aggregating by week.");
}

globalStats = await client.Statistics.GetGlobalStatisticsAsync(startDate, endDate, AggregateBy.Month, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of GLOBAL stats in {startDate.Year} and aggregated by month: {globalStats.Length}").ConfigureAwait(false);
Expand All @@ -42,8 +56,16 @@ public async Task RunAsync(IClient client, TextWriter log, CancellationToken can
countryStats = await client.Statistics.GetCountryStatisticsAsync(null, startDate, endDate, AggregateBy.Day, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of COUNTRY stats in {startDate.Year} and aggregated by day: {countryStats.Length}").ConfigureAwait(false);

countryStats = await client.Statistics.GetCountryStatisticsAsync(null, startDate, endDate, AggregateBy.Week, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of COUNTRY stats in {startDate.Year} and aggregated by week: {countryStats.Length}").ConfigureAwait(false);
// SendGrid can't handle years that have more than 52 weeks (like 2015 and 2020 for example).
try
{
countryStats = await client.Statistics.GetCountryStatisticsAsync(null, startDate, endDate, AggregateBy.Week, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of COUNTRY stats in {startDate.Year} and aggregated by week: {countryStats.Length}").ConfigureAwait(false);
}
catch (SendGridException e) when (e.Message.Equals("unable to get stats", StringComparison.OrdinalIgnoreCase))
{
await log.WriteLineAsync($"The SendGrid API returned an exception: '{e.Message}'. Typically, this indicates that there is more than 52 weeks in the current year which is a situation that SendGrid can't handle when aggregating by week.");
}

countryStats = await client.Statistics.GetCountryStatisticsAsync(null, startDate, endDate, AggregateBy.Month, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of COUNTRY stats in {startDate.Year} and aggregated by month: {countryStats.Length}").ConfigureAwait(false);
Expand All @@ -55,8 +77,15 @@ public async Task RunAsync(IClient client, TextWriter log, CancellationToken can
browserStats = await client.Statistics.GetBrowsersStatisticsAsync(null, startDate, endDate, AggregateBy.Day, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of BROWSER stats in {startDate.Year} and aggregated by day: {browserStats.Length}").ConfigureAwait(false);

browserStats = await client.Statistics.GetBrowsersStatisticsAsync(null, startDate, endDate, AggregateBy.Week, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of BROWSER stats in {startDate.Year} and aggregated by week: {browserStats.Length}").ConfigureAwait(false);
try
{
browserStats = await client.Statistics.GetBrowsersStatisticsAsync(null, startDate, endDate, AggregateBy.Week, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of BROWSER stats in {startDate.Year} and aggregated by week: {browserStats.Length}").ConfigureAwait(false);
}
catch (SendGridException e) when (e.Message.Equals("unable to get stats", StringComparison.OrdinalIgnoreCase))
{
await log.WriteLineAsync($"The SendGrid API returned an exception: '{e.Message}'. Typically, this indicates that there is more than 52 weeks in the current year which is a situation that SendGrid can't handle when aggregating by week.");
}

browserStats = await client.Statistics.GetBrowsersStatisticsAsync(null, startDate, endDate, AggregateBy.Month, null, cancellationToken).ConfigureAwait(false);
await log.WriteLineAsync($"Number of BROWSER stats in {startDate.Year} and aggregated by month: {browserStats.Length}").ConfigureAwait(false);
Expand Down
2 changes: 1 addition & 1 deletion Source/StrongGrid.UnitTests/StrongGrid.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="RichardSzalay.MockHttp" Version="6.0.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
Expand Down
11 changes: 10 additions & 1 deletion Source/StrongGrid/Models/Webhooks/ProcessedEvent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using StrongGrid.Utilities;
using System;

Expand Down Expand Up @@ -37,5 +37,14 @@ public class ProcessedEvent : DeliveryEvent
[JsonProperty("send_at", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(EpochConverter))]
public DateTime ProcessedOn { get; set; }

/// <summary>
/// Gets or sets the IP Pool (if specified when the email was sent).
/// </summary>
/// <value>
/// The IP pool use when the email was sent.
/// </value>
[JsonProperty("pool", NullValueHandling = NullValueHandling.Ignore)]
public IpPool IpPool { get; set; }
}
}
7 changes: 5 additions & 2 deletions build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

// Install tools.
#tool nuget:?package=GitVersion.CommandLine&version=5.1.3
#tool nuget:?package=GitReleaseManager&version=0.9.0
#tool nuget:?package=GitReleaseManager&version=0.10.3
#tool nuget:?package=OpenCover&version=4.7.922
#tool nuget:?package=ReportGenerator&version=4.4.0
#tool nuget:?package=ReportGenerator&version=4.4.7
#tool nuget:?package=coveralls.io&version=1.4.2
#tool nuget:?package=xunit.runner.console&version=2.4.1

Expand Down Expand Up @@ -195,6 +195,7 @@ Task("Run-Unit-Tests")
DotNetCoreTest(unitTestsProject, new DotNetCoreTestSettings
{
NoBuild = true,
NoRestore = true,
Configuration = configuration
});
});
Expand All @@ -206,6 +207,7 @@ Task("Run-Code-Coverage")
Action<ICakeContext> testAction = ctx => ctx.DotNetCoreTest(unitTestsProject, new DotNetCoreTestSettings
{
NoBuild = true,
NoRestore = true,
Configuration = configuration
});

Expand Down Expand Up @@ -252,6 +254,7 @@ Task("Create-NuGet-Package")
IncludeSource = false,
IncludeSymbols = true,
NoBuild = true,
NoRestore = true,
NoDependencies = true,
OutputDirectory = outputDir,
ArgumentCustomization = (args) =>
Expand Down
2 changes: 1 addition & 1 deletion tools/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Cake" version="0.35.0" />
<package id="Cake" version="0.37.0" />
</packages>

0 comments on commit 4a8e678

Please sign in to comment.