From c5e0a64ca5a7b9f4954879ac7972807bb1ce5119 Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Wed, 12 Jun 2024 21:09:31 +0200 Subject: [PATCH] Fix new issue with hotfix EFCore .Find() is a bad dogshit API that shouldn't exist, and it started exploding with the recent hotfix. --- .../Controllers/GitHubWebhookController.cs | 18 +++++++++--------- SS14.MapServer/Models/Context.cs | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/SS14.MapServer/Controllers/GitHubWebhookController.cs b/SS14.MapServer/Controllers/GitHubWebhookController.cs index ec5a463..8da3ea8 100644 --- a/SS14.MapServer/Controllers/GitHubWebhookController.cs +++ b/SS14.MapServer/Controllers/GitHubWebhookController.cs @@ -187,10 +187,10 @@ private async Task> CheckFiles(long installationId, long rep private async Task CreateInitialPrComment(PullRequestEventPayload payload, GitReference baseCommit, List files) { // ReSharper disable once MethodHasAsyncOverload - var prComment = _context.PullRequestComment?.Find( - baseCommit.User.Login, - baseCommit.Repository.Name, - payload.PullRequest.Number); + var prComment = await _context.PullRequestComment.SingleOrDefaultAsync( + prc => prc.Owner == baseCommit.User.Login + && prc.Repository == baseCommit.Repository.Name + && prc.IssueNumber == payload.PullRequest.Number); if (prComment != null) return; @@ -250,10 +250,10 @@ private async Task OnPrProcessingResult(IServiceProvider serviceProvider, MapPro } // ReSharper disable once MethodHasAsyncOverload - var prComment = _context.PullRequestComment?.Find( - pullRequest.Base.User.Login, - pullRequest.Base.Repository.Name, - pullRequest.Number); + var prComment = await _context.PullRequestComment.SingleOrDefaultAsync( + prc => prc.Owner == pullRequest.Base.User.Login + && prc.Repository == pullRequest.Base.Repository.Name + && prc.IssueNumber == pullRequest.Number); var issue = new IssueIdentifier( pullRequest.Base.User.Login, @@ -293,7 +293,7 @@ private void SavePrComment(long? commentId, IssueIdentifier issue) IssueNumber = issue.IssueId, CommentId = commentId.Value }; - _context.PullRequestComment?.Add(prComment); + _context.PullRequestComment.Add(prComment); _context.SaveChanges(); } diff --git a/SS14.MapServer/Models/Context.cs b/SS14.MapServer/Models/Context.cs index c5eb771..7e63e1a 100644 --- a/SS14.MapServer/Models/Context.cs +++ b/SS14.MapServer/Models/Context.cs @@ -10,7 +10,7 @@ public class Context : DbContext public DbSet? Image { get; set; } public DbSet? Grid { get; set; } - public DbSet? PullRequestComment { get; set; } + public DbSet PullRequestComment { get; set; } = default!; public Context(DbContextOptions options) : base(options) {}