diff --git a/.travis.yml b/.travis.yml index a213af0..eb70465 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,6 @@ stages: - test - publish - deploy - - database jobs: include: @@ -56,16 +55,3 @@ jobs: - curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash script: - ./deploy-app.sh - - - stage: database - name: database migrations and updates - if: tag IS present - env: - global: - - DOTNET_ENVIRONMENT="Azure" - before_script: - - sudo snap alias dotnet-sdk.dotnet dotnet - script: - - ./execute-database-updates.sh - - rm -rf publish - - ./execute-database-migrations diff --git a/src/Covid19Api.AutoMapper/CountryStatsProfile.cs b/src/Covid19Api.AutoMapper/CountryStatsProfile.cs index 962ae4a..b3f26fe 100644 --- a/src/Covid19Api.AutoMapper/CountryStatsProfile.cs +++ b/src/Covid19Api.AutoMapper/CountryStatsProfile.cs @@ -12,8 +12,7 @@ public CountryStatsProfile() { this.CreateMap() .ConvertUsing(src => new CountryStatisticsDto(src.Country, src.CountryCode, src.TotalCases, - src.NewCases, src.TotalDeaths, - src.NewDeaths, src.RecoveredCases, src.ActiveCases, src.SeriousCases, src.FetchedAt)); + src.NewCases, src.TotalDeaths, src.NewDeaths, src.RecoveredCases, src.ActiveCases, src.FetchedAt)); } } } \ No newline at end of file diff --git a/src/Covid19Api.Domain/CountryStatistics.cs b/src/Covid19Api.Domain/CountryStatistics.cs index dfcd679..877d930 100644 --- a/src/Covid19Api.Domain/CountryStatistics.cs +++ b/src/Covid19Api.Domain/CountryStatistics.cs @@ -28,13 +28,11 @@ public class CountryStatistics public int ActiveCases { get; private set; } - public int SeriousCases { get; private set; } - public DateTime FetchedAt { get; private set; } public CountryStatistics(string country, string? countryCode, int totalCases, int newCases, int totalDeaths, int newDeaths, - int recoveredCases, int activeCases, int seriousCases, DateTime fetchedAt) + int recoveredCases, int activeCases, DateTime fetchedAt) { this.Country = country; this.CountryCode = countryCode; @@ -44,7 +42,6 @@ public CountryStatistics(string country, string? countryCode, int totalCases, in this.NewDeaths = newDeaths; this.RecoveredCases = recoveredCases; this.ActiveCases = activeCases; - this.SeriousCases = seriousCases; this.FetchedAt = fetchedAt; this.Id = this.Generate(); } @@ -53,8 +50,7 @@ public bool Empty() { return this.TotalCases == 0 && this.NewCases == 0 && this.TotalDeaths == 0 && this.NewDeaths == 0 && - this.RecoveredCases == 0 && this.ActiveCases == 0 && - this.SeriousCases == 0; + this.RecoveredCases == 0 && this.ActiveCases == 0; } private Guid Generate() diff --git a/src/Covid19Api.Domain/CountryStatisticsAggregate.cs b/src/Covid19Api.Domain/CountryStatisticsAggregate.cs new file mode 100644 index 0000000..1bdf7f1 --- /dev/null +++ b/src/Covid19Api.Domain/CountryStatisticsAggregate.cs @@ -0,0 +1,61 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace Covid19Api.Domain +{ + // ReSharper disable UnusedAutoPropertyAccessor.Local + // ReSharper disable AutoPropertyCanBeMadeGetOnly.Local + // ReSharper disable UnusedAutoPropertyAccessor.Global + public class CountryStatisticsAggregate + { + public Guid Id { get; private set; } + + public string Country { get; private set; } + + public string? CountryCode { get; private set; } + + public int Total { get; private set; } + + public int New { get; private set; } + + public int Deaths { get; private set; } + + public int NewDeaths { get; private set; } + + public int Recovered { get; private set; } + + public int Active { get; private set; } + public int Month { get; private set; } + public int Year { get; private set; } + + + public CountryStatisticsAggregate(string country, string? countryCode, int total, int @new, int deaths, + int newDeaths, + int recovered, int active, int month, int year) + { + this.Country = country; + this.CountryCode = countryCode; + this.Total = total; + this.New = @new; + this.Deaths = deaths; + this.NewDeaths = newDeaths; + this.Recovered = recovered; + this.Active = active; + this.Month = month; + this.Year = year; + this.Id = this.Generate(); + } + + private Guid Generate() + { + using var hasher = MD5.Create(); + + var valueToHash = $"{nameof(CountryStatisticsAggregate)}_{this.Country}_{this.Month}_{this.Year}"; + + var hashed = hasher.ComputeHash(Encoding.UTF8.GetBytes(valueToHash)); + + return new Guid(hashed); + } + } +} \ No newline at end of file diff --git a/src/Covid19Api.Presentation/Response/CountryStatisticsDto.cs b/src/Covid19Api.Presentation/Response/CountryStatisticsDto.cs index b021534..693ffa8 100644 --- a/src/Covid19Api.Presentation/Response/CountryStatisticsDto.cs +++ b/src/Covid19Api.Presentation/Response/CountryStatisticsDto.cs @@ -20,13 +20,11 @@ public class CountryStatisticsDto public int ActiveCases { get; } - public int SeriousCases { get; } - public DateTime FetchedAt { get; } public CountryStatisticsDto(string country, string? countryCode, int totalCases, int newCases, int totalDeaths, int newDeaths, - int recoveredCases, int activeCases, int seriousCases, DateTime fetchedAt) + int recoveredCases, int activeCases, DateTime fetchedAt) { this.Country = country; this.CountryCode = countryCode; @@ -36,7 +34,6 @@ public CountryStatisticsDto(string country, string? countryCode, int totalCases, this.NewDeaths = newDeaths; this.RecoveredCases = recoveredCases; this.ActiveCases = activeCases; - this.SeriousCases = seriousCases; this.FetchedAt = fetchedAt; } } diff --git a/src/Covid19Api.Services/Loader/CountryStatisticsLoader.cs b/src/Covid19Api.Services/Loader/CountryStatisticsLoader.cs index a331b9d..9396ff1 100644 --- a/src/Covid19Api.Services/Loader/CountryStatisticsLoader.cs +++ b/src/Covid19Api.Services/Loader/CountryStatisticsLoader.cs @@ -50,14 +50,14 @@ public CountryStatisticsLoader(ICountryMetaDataLoader countryMetaDataLoader, var newDeaths = ParseIntegerValue(tableDataNodes[5]); var recovered = ParseIntegerValue(tableDataNodes[6]); var active = ParseIntegerValue(tableDataNodes[8]); - var serious = ParseIntegerValue(tableDataNodes[9]); + // This would be serious: var serious = ParseIntegerValue(tableDataNodes[9]) if (string.IsNullOrWhiteSpace(country)) return null; var countryCode = GetCountryCode(countryMetaData, country); return new CountryStatistics(country, countryCode, totalCases, newCases, totalDeaths, newDeaths, recovered, - active, serious, fetchedAt); + active, fetchedAt); } private static string? GetCountryCode(IEnumerable countryMetaData, string country)