Skip to content

Commit

Permalink
Merge pull request #40 from bobbahbrown/v1.3.9
Browse files Browse the repository at this point in the history
Version 1.3.9 - Add Logging for Ban Parsing
  • Loading branch information
bobbah authored Aug 20, 2021
2 parents 89b54cf + 3d86a0a commit 39a2199
Show file tree
Hide file tree
Showing 39 changed files with 1,893 additions and 282 deletions.
13 changes: 7 additions & 6 deletions CentCom.API/CentCom.API.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.3.8.1</Version>
<Version>1.3.9</Version>
<UserSecretsId>1f5f48fa-862f-4472-ba34-2c5a26035e88</UserSecretsId>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -16,13 +17,13 @@
<ItemGroup>
<PackageReference Include="BuildBundlerMinifier" Version="3.2.449" />
<PackageReference Include="Enums.NET" Version="4.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" />
<PackageReference Include="Npgsql" Version="5.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="6.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.1.5" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.1.5" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUi" Version="6.1.5" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions CentCom.Common/CentCom.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<Version>1.3.8.1</Version>
<Version>1.3.9</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EFCore.NamingConventions" Version="5.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.9" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Npgsql" Version="5.0.7" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7" />
Expand Down
9 changes: 9 additions & 0 deletions CentCom.Common/Data/DatabaseContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public abstract class DatabaseContext : DbContext
public DbSet<BanSource> BanSources { get; set; }
public DbSet<JobBan> JobBans { get; set; }
public DbSet<FlatBansVersion> FlatBansVersion { get; set; }
public DbSet<CheckHistory> CheckHistory { get; set; }

public DatabaseContext(IConfiguration configuration)
{
Expand Down Expand Up @@ -67,6 +68,14 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.Version).IsRequired();
entity.HasIndex(e => new { e.Name, e.Version }).IsUnique();
});

modelBuilder.Entity<CheckHistory>(entity =>
{
entity.HasKey(e => e.Id);
entity.Property(e => e.Id).UseIdentityAlwaysColumn();
entity.Property(e => e.Parser).IsRequired();
entity.HasIndex(e => new {e.Parser, e.Started});
});
}

public async Task<bool> Migrate(CancellationToken cancellationToken)
Expand Down
21 changes: 21 additions & 0 deletions CentCom.Common/Data/DesignTime/MariaDbContextFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;

namespace CentCom.Common.Data.DesignTime
{
public class MariaDbContextFactory : IDesignTimeDbContextFactory<MariaDbContext>
{
public MariaDbContext CreateDbContext(string[] args)
{
var conf = new Dictionary<string, string>
{
{ "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
{ "dbConfig:dbType", "MariaDb" },
{ "dbConfig:efcoreBuild", "any-value" }
};
IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
return new MariaDbContext(spoofedConfig);
}
}
}
3 changes: 2 additions & 1 deletion CentCom.Common/Data/DesignTime/MySqlDbContextFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ public MySqlDbContext CreateDbContext(string[] args)
var conf = new Dictionary<string, string>
{
{ "dbConfig:connectionString", "Host=127.0.0.1;Database=centcom_design;Username=centcom_parser;Password=spoof" },
{ "dbConfig:dbType", "Postgres" }
{ "dbConfig:dbType", "MySql" },
{ "dbConfig:efcoreBuild", "any-value" }
};
IConfiguration spoofedConfig = new ConfigurationBuilder().AddInMemoryCollection(conf).Build();
return new MySqlDbContext(spoofedConfig);
Expand Down
21 changes: 21 additions & 0 deletions CentCom.Common/Data/MariaDbContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;

namespace CentCom.Common.Data
{
public class MariaDbContext : DatabaseContext
{
public MariaDbContext(IConfiguration configuration) : base(configuration)
{
}

protected override void OnConfiguring(DbContextOptionsBuilder options)
{
var connStr = Configuration.GetSection("dbConfig")["connectionString"];
var efcoreBuild =
Configuration.GetSection("dbConfig")["efcoreBuild"] != null; // Used for building migrations
options.UseMySql(connStr,
efcoreBuild ? MariaDbServerVersion.LatestSupportedServerVersion : ServerVersion.AutoDetect(connStr));
}
}
}
10 changes: 4 additions & 6 deletions CentCom.Common/Data/MySqlDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ public MySqlDbContext(IConfiguration configuration) : base(configuration)
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
var connStr = Configuration.GetSection("dbConfig")["connectionString"];
options.UseMySql(connStr, ServerVersion.AutoDetect(connStr));
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
var efcoreBuild =
Configuration.GetSection("dbConfig")["efcoreBuild"] != null; // Used for building migrations
options.UseMySql(connStr,
efcoreBuild ? MySqlServerVersion.LatestSupportedServerVersion : ServerVersion.AutoDetect(connStr));
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 39a2199

Please sign in to comment.