Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
Fixed Crash Reports search
  • Loading branch information
Aragas committed Jun 26, 2024
1 parent 9bf6c17 commit d9011ab
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BUTR.Site.NexusMods.Server.Models;
using BUTR.Site.NexusMods.Server.Models.Database;
using BUTR.Site.NexusMods.Server.ValueObjects.Utils;

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

using System;
using System.Collections.Generic;
using System.Threading;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;

using System;
using System.Collections.Generic;
using System.Threading;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class NexusModsArticleController : ApiControllerBase
public sealed record NexusModsArticleModel
{
public NexusModsArticleId NexusModsArticleId { get; init; }
public string Title { get; init; }
public string Title { get; init; } = default!;
public NexusModsUserId NexusModsUserId { get; init; }
public NexusModsUserName Author { get; init; }
public DateTimeOffset CreateDate { get; init; }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using BUTR.Site.NexusMods.Server.Extensions;
using BUTR.Site.NexusMods.Server.Models;
using BUTR.Site.NexusMods.Server.Models.API;
using BUTR.Site.NexusMods.Server.Models.Database;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BUTR.Site.NexusMods.Server.Extensions;
using BUTR.Site.NexusMods.Server.Models;
using BUTR.Site.NexusMods.Server.Models.Database;
using BUTR.Site.NexusMods.Server.Repositories;

using Microsoft.Extensions.DependencyInjection;
Expand All @@ -9,7 +8,6 @@
using Quartz;

using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

Expand Down
3 changes: 0 additions & 3 deletions src/BUTR.Site.NexusMods.Server/Models/API/MessageResponse.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using BUTR.Site.NexusMods.Server.Extensions;

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;

namespace BUTR.Site.NexusMods.Server.Models.Database;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed record NexusModsModToModuleInfoHistoryGameVersionEntity : IEntityW

public required GameVersion GameVersion { get; init; }

public NexusModsModToModuleInfoHistoryEntity MainEntity { get; init; }
public NexusModsModToModuleInfoHistoryEntity MainEntity { get; init; } = default!;

public override int GetHashCode() => HashCode.Combine(TenantId, NexusModsModId, ModuleId, ModuleVersion, NexusModsFileId, GameVersion);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,30 @@

namespace BUTR.Site.NexusMods.Server.Repositories;

public sealed record ModuleIdToVersionModel
{
public required ModuleId ModuleId { get; init; }
public required ModuleVersion Version { get; init; }
}
public sealed record UserCrashReportModel
{
public required CrashReportId Id { get; init; }
public required CrashReportVersion Version { get; init; }
public required GameVersion GameVersion { get; init; }
public required ExceptionTypeId ExceptionType { get; init; }
public required string Exception { get; init; }
public required DateTimeOffset CreatedAt { get; init; }
//public required ModuleId[] ModuleIds { get; init; }
//public required ModuleIdToVersionModel[] ModuleIdToVersion { get; init; }
public required ModuleId? TopInvolvedModuleId { get; init; } // Used for FE search
public required ModuleId[] InvolvedModuleIds { get; init; }
//public required NexusModsModId[] NexusModsModIds { get; init; }
public required CrashReportUrl Url { get; init; }

public required CrashReportStatus Status { get; init; }
public required string? Comment { get; init; }
}

public interface ICrashReportEntityRepositoryRead : IRepositoryRead<CrashReportEntity>
{
Task<Paging<UserCrashReportModel>> GetCrashReportsPaginatedAsync(NexusModsUserEntity user, PaginatedQuery query, ApplicationRole applicationRole, CancellationToken ct);
Expand Down Expand Up @@ -89,7 +113,7 @@ IQueryable<UserCrashReportModel> DbQueryBase(Expression<Func<CrashReportEntity,
Url = x.Url,
//ModuleIds = x.ModuleInfos.Select(y => y.Module).Select(y => y.ModuleId).ToArray(),
//ModuleIdToVersion = x.ModuleInfos.Select(y => new ModuleIdToVersionView { ModuleId = y.Module.ModuleId, Version = y.Version }).ToArray(),
//TopInvolvedModuleId = x.ModuleInfos.OrderBy(y => y.InvolvedPosition).Where(z => z.IsInvolved).Select(y => y.Module).Select(y => y.ModuleId).Cast<ModuleId?>().FirstOrDefault(),
TopInvolvedModuleId = x.ModuleInfos.OrderBy(y => y.InvolvedPosition).Where(z => z.IsInvolved).Select(y => y.Module).Select(y => y.ModuleId).Cast<ModuleId?>().FirstOrDefault(),
InvolvedModuleIds = x.ModuleInfos.OrderBy(y => y.InvolvedPosition).Where(z => z.IsInvolved).Select(y => y.Module).Select(y => y.ModuleId).ToArray(),
//NexusModsModIds = x.ModuleInfos.Select(y => y.NexusModsMod).Where(y => y != null).Select(y => y!.NexusModsModId).ToArray(),
Status = x.ToUsers.Where(y => y.NexusModsUser.NexusModsUserId == user.NexusModsUserId).Select(y => y.Status).FirstOrDefault(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using BUTR.Site.NexusMods.Server.Contexts;
using BUTR.Site.NexusMods.Server.Models.Database;

using Microsoft.EntityFrameworkCore;

using System.Linq;

namespace BUTR.Site.NexusMods.Server.Repositories;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

using Microsoft.EntityFrameworkCore;

using System;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -31,30 +30,6 @@ public sealed record UserLinkedModModel
public required ModuleId[] KnownModuleIds { get; init; }
}

public sealed record ModuleIdToVersionModel
{
public required ModuleId ModuleId { get; init; }
public required ModuleVersion Version { get; init; }
}
public sealed record UserCrashReportModel
{
public required CrashReportId Id { get; init; }
public required CrashReportVersion Version { get; init; }
public required GameVersion GameVersion { get; init; }
public required ExceptionTypeId ExceptionType { get; init; }
public required string Exception { get; init; }
public required DateTimeOffset CreatedAt { get; init; }
//public required ModuleId[] ModuleIds { get; init; }
//public required ModuleIdToVersionModel[] ModuleIdToVersion { get; init; }
//public required ModuleId? TopInvolvedModuleId { get; init; }
public required ModuleId[] InvolvedModuleIds { get; init; }
//public required NexusModsModId[] NexusModsModIds { get; init; }
public required CrashReportUrl Url { get; init; }

public required CrashReportStatus Status { get; init; }
public required string? Comment { get; init; }
}

public interface INexusModsUserRepositoryRead : IRepositoryRead<NexusModsUserEntity>
{
Task<NexusModsUserEntity?> GetUserWithIntegrationsAsync(NexusModsUserId userId, CancellationToken ct);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Microsoft.Extensions.Options;

using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,14 @@ public async Task<bool> SetGlobalMetadataAsync(IReadOnlyList<DiscordGlobalMetada
if (DateTimeOffset.UtcNow <= tokens.ExpiresAt)
return tokens;

using var request = new HttpRequestMessage(HttpMethod.Post, "v10/oauth2/token")
using var request = new HttpRequestMessage(HttpMethod.Post, "v10/oauth2/token");
request.Content = new FormUrlEncodedContent(new List<KeyValuePair<string, string>>
{
Content = new FormUrlEncodedContent(new List<KeyValuePair<string, string>>
{
new("client_id", _options.ClientId),
new("redirect_uri", _options.RedirectUri),
new("grant_type", "refresh_token"),
new("refresh_token", tokens.RefreshToken),
})
};
new("client_id", _options.ClientId),
new("redirect_uri", _options.RedirectUri),
new("grant_type", "refresh_token"),
new("refresh_token", tokens.RefreshToken),
});
using var response = await _httpClient.SendAsync(request, ct);
if (!response.IsSuccessStatusCode) return null;
var responseData = await JsonSerializer.DeserializeAsync<DiscordOAuthTokensResponse>(await response.Content.ReadAsStreamAsync(ct), cancellationToken: ct);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Microsoft.Extensions.Options;

using System;
using System.Net.Http;
using System.Text.Json;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Options;

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Microsoft.Extensions.Options;

using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text.Json;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ public sealed class NexusModsAPIv2Client : INexusModsAPIv2Client
{
private record GraphQLQuery
{
public string Query { get; init; }
public string Query { get; init; } = default!;
}

private record GraphQLResponse<TData>(TData Data);
private record GraphQLGetUserByNameResponse
{
public string MemberId { get; init; }
public string MemberId { get; init; } = default!;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using HtmlAgilityPack;

using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

using Microsoft.Extensions.Options;

using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text.Json;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
Expand Down

0 comments on commit d9011ab

Please sign in to comment.