Skip to content

Commit

Permalink
Merge pull request #38 from BUTR/code-formatting/fix-codeformatting
Browse files Browse the repository at this point in the history
Automated PR to fix formatting errors
  • Loading branch information
Aragas authored Mar 4, 2024
2 parents a91a2d2 + e94a2dc commit 2d09958
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 37 deletions.
2 changes: 1 addition & 1 deletion src/BUTR.CrashReportServer/Contexts/AppDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AppDbContext : DbContext
public DbSet<IdEntity> IdEntities { get; set; }
public DbSet<FileEntity> FileEntities { get; set; }
public DbSet<JsonEntity> JsonEntities { get; set; }

public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) { }

protected override void OnModelCreating(ModelBuilder modelBuilder)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public sealed record CrashReportUploadBody(CrashReportModel CrashReport, ICollec
{
Converters = { new JsonStringEnumConverter() }
};

private readonly ILogger _logger;
private readonly CrashUploadOptions _options;
private readonly JsonSerializerOptions _jsonSerializerOptions;
Expand All @@ -58,7 +58,7 @@ public CrashUploadController(
var meter = meterFactory.Create("BUTR.CrashReportServer.Controllers.CrashUploadController", "1.0.0");

_reportVersion = meter.CreateCounter<int>("report-version", unit: "Count");

_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_jsonSerializerOptions = jsonSerializerOptions.Value ?? throw new ArgumentNullException(nameof(jsonSerializerOptions));
_options = options.Value ?? throw new ArgumentNullException(nameof(options));
Expand Down Expand Up @@ -128,8 +128,8 @@ private async Task<IActionResult> UploadJsonAsync(CancellationToken ct)
await _dbContext.FileEntities.AddAsync(new FileEntity { FileId = idEntity.FileId, DataCompressed = compressedHtmlStream.ToArray(), }, ct);
await _dbContext.SaveChangesAsync(ct);

_reportVersion.Add(1, new[] {new KeyValuePair<string, object?>("Version", crashReport.Version)});
_reportVersion.Add(1, new[] { new KeyValuePair<string, object?>("Version", crashReport.Version) });

return Ok($"{_options.BaseUri}/{idEntity.FileId}");
}

Expand Down
6 changes: 3 additions & 3 deletions src/BUTR.CrashReportServer/Controllers/ReportController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private async Task<IActionResult> GetJson(string filename, CancellationToken ct)
{
Response.Headers.ContentEncoding = "gzip";
return File(await _gZipCompressor.CompressAsync(new MemoryStream(Encoding.UTF8.GetBytes(file.CrashReport)), ct), "application/json; charset=utf-8", true);

}
return File(new MemoryStream(Encoding.UTF8.GetBytes(file.CrashReport)), "application/json; charset=utf-8", true);
}
Expand Down Expand Up @@ -198,7 +198,7 @@ public IActionResult SitemapIndex()
{
var count = _dbContext.IdEntities.Count();
var sitemaps = (count / 50000) + 1;

var sitemap = new SitemapIndex
{
Sitemap = Enumerable.Range(0, sitemaps).Select(x => new Sitemap
Expand All @@ -208,7 +208,7 @@ public IActionResult SitemapIndex()
};
return Ok(sitemap);
}

[AllowAnonymous]
[HttpGet("sitemap_{idx:int}.xml")]
[Produces("application/xml")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;

using System;

#nullable disable

Expand Down Expand Up @@ -80,4 +81,4 @@ protected override void Down(MigrationBuilder migrationBuilder)
name: "id_entity");
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Xml.Serialization;

namespace BUTR.CrashReportServer.Models.Sitemaps;
Expand Down
8 changes: 4 additions & 4 deletions src/BUTR.CrashReportServer/Models/Sitemaps/Sitemap.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System.Xml.Serialization;
using System.Xml.Serialization;

namespace BUTR.CrashReportServer.Models.Sitemaps;

[XmlRoot(ElementName="sitemap", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
[XmlRoot(ElementName = "sitemap", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public class Sitemap
{
[XmlElement(ElementName="loc", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
{
[XmlElement(ElementName = "loc", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public string Location { get; set; }
}
8 changes: 4 additions & 4 deletions src/BUTR.CrashReportServer/Models/Sitemaps/SitemapIndex.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace BUTR.CrashReportServer.Models.Sitemaps;

[XmlRoot(ElementName="sitemapindex", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
[XmlRoot(ElementName = "sitemapindex", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public class SitemapIndex
{
{

[XmlElement(ElementName="sitemap", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
[XmlElement(ElementName = "sitemap", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public List<Sitemap> Sitemap { get; set; }
}
14 changes: 7 additions & 7 deletions src/BUTR.CrashReportServer/Models/Sitemaps/Url.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
using System;
using System;
using System.Xml.Serialization;

namespace BUTR.CrashReportServer.Models.Sitemaps;

[XmlRoot(ElementName="url", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
[XmlRoot(ElementName = "url", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public class Url
{
[XmlElement(ElementName="loc", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
[XmlElement(ElementName = "loc", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public string Location { get; set; }

[XmlIgnore]
public DateTime TimeStamp { get; set; }
[XmlElement(ElementName="lastmod", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]

[XmlElement(ElementName = "lastmod", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public string LastMod
{
get => TimeStamp.ToString("yyyy-MM-ddTHH:mm:sszzz");
set => TimeStamp = DateTime.Parse(value);
}

[XmlElement(ElementName="changefreq", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
[XmlElement(ElementName = "changefreq", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public ChangeFrequency ChangeFrequency { get; set; }

[XmlElement(ElementName="priority", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
[XmlElement(ElementName = "priority", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public double Priority { get; set; }
}
11 changes: 6 additions & 5 deletions src/BUTR.CrashReportServer/Models/Sitemaps/Urlset.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Xml.Serialization;

namespace BUTR.CrashReportServer.Models.Sitemaps;

[XmlRoot(ElementName="urlset", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
public class Urlset {
[XmlRoot(ElementName = "urlset", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public class Urlset
{

[XmlElement(ElementName="url", Namespace="http://www.sitemaps.org/schemas/sitemap/0.9")]
public List<Url> Url { get; set; }
[XmlElement(ElementName = "url", Namespace = "http://www.sitemaps.org/schemas/sitemap/0.9")]
public List<Url> Url { get; set; }
}
2 changes: 1 addition & 1 deletion src/BUTR.CrashReportServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static async Task Main(string[] args)
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateBootstrapLogger();

try
{
Log.Information("Starting web application");
Expand Down
4 changes: 2 additions & 2 deletions src/BUTR.CrashReportServer/Services/HexGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ public HashSet<string> GetHex(int maxCount, int length)
{
var charLength = length * 2;
var byteLength = length;

Span<char> output = stackalloc char[maxCount * charLength];
Span<byte> input = stackalloc byte[maxCount * byteLength];
_random.GetBytes(input);

var unique = new HashSet<string>(maxCount);
GenerateHexChars(input, output);
for (var i = 0; i < output.Length; i += charLength)
Expand Down
4 changes: 2 additions & 2 deletions src/BUTR.CrashReportServer/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void ConfigureServices(IServiceCollection services)
opts.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
opts.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));
});

services.AddResponseCaching();
}

Expand All @@ -126,7 +126,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
app.UseSwaggerUI(options => options.SwaggerEndpoint("/swagger/v1/swagger.json", _appName));

app.UseRouting();

app.UseResponseCaching();

app.UseAuthentication();
Expand Down

0 comments on commit 2d09958

Please sign in to comment.