Skip to content

Commit

Permalink
Update SS14.GithubApiHelper dependency
Browse files Browse the repository at this point in the history
Update octokit
Fix github api related IDs being int instead of long
Change usages of .Find to .Where
Fix dbset nullability
  • Loading branch information
juliangiebel committed Feb 26, 2025
1 parent c4d5e88 commit 45d5d91
Show file tree
Hide file tree
Showing 9 changed files with 346 additions and 27 deletions.
2 changes: 1 addition & 1 deletion SS14.GithubApiHelper
21 changes: 11 additions & 10 deletions SS14.MapServer/Controllers/GitHubWebhookController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,11 @@ private async Task<IEnumerable<string>> CheckFiles(long installationId, long rep

private async Task CreateInitialPrComment(PullRequestEventPayload payload, GitReference baseCommit, List<string?> files)
{
// ReSharper disable once MethodHasAsyncOverload
var prComment = _context.PullRequestComment?.Find(
baseCommit.User.Login,
baseCommit.Repository.Name,
payload.PullRequest.Number);
var prComment = await _context.PullRequestComment.Where(pr =>
pr.Owner == baseCommit.User.Login
&& pr.Repository == baseCommit.Repository.Name
&& pr.IssueNumber == payload.PullRequest.Number
).SingleOrDefaultAsync();

if (prComment != null)
return;
Expand Down Expand Up @@ -250,10 +250,11 @@ 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.Where(pr =>
pr.Owner == pullRequest.Base.User.Login
&& pr.Repository == pullRequest.Base.Repository.Name
&& pr.IssueNumber == pullRequest.Number
).SingleOrDefaultAsync();

var issue = new IssueIdentifier(
pullRequest.Base.User.Login,
Expand Down Expand Up @@ -281,7 +282,7 @@ await _githubApiService.UpdateCommentWithTemplate(
}
}

private void SavePrComment(int? commentId, IssueIdentifier issue)
private void SavePrComment(long? commentId, IssueIdentifier issue)
{
if (!commentId.HasValue)
return;
Expand Down
267 changes: 267 additions & 0 deletions SS14.MapServer/Migrations/20250225225635_VersionUpgrade.Designer.cs

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

50 changes: 50 additions & 0 deletions SS14.MapServer/Migrations/20250225225635_VersionUpgrade.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace SS14.MapServer.Migrations
{
/// <inheritdoc />
public partial class VersionUpgrade : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<long>(
name: "CommentId",
table: "PullRequestComment",
type: "bigint",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");

migrationBuilder.AlterColumn<long>(
name: "IssueNumber",
table: "PullRequestComment",
type: "bigint",
nullable: false,
oldClrType: typeof(int),
oldType: "integer");
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "CommentId",
table: "PullRequestComment",
type: "integer",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint");

migrationBuilder.AlterColumn<int>(
name: "IssueNumber",
table: "PullRequestComment",
type: "integer",
nullable: false,
oldClrType: typeof(long),
oldType: "bigint");
}
}
}
10 changes: 5 additions & 5 deletions SS14.MapServer/Migrations/ContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("ProductVersion", "8.0.1")
.HasAnnotation("Relational:MaxIdentifierLength", 63);

NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
Expand Down Expand Up @@ -122,11 +122,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<string>("Repository")
.HasColumnType("text");

b.Property<int>("IssueNumber")
.HasColumnType("integer");
b.Property<long>("IssueNumber")
.HasColumnType("bigint");

b.Property<int>("CommentId")
.HasColumnType("integer");
b.Property<long>("CommentId")
.HasColumnType("bigint");

b.HasKey("Owner", "Repository", "IssueNumber");

Expand Down
Loading

0 comments on commit 45d5d91

Please sign in to comment.