Skip to content

Commit

Permalink
Support settings autotag foundations
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-bstein committed Sep 17, 2024
1 parent 6c4582f commit 2f227a8
Show file tree
Hide file tree
Showing 30 changed files with 4,259 additions and 26 deletions.
2 changes: 2 additions & 0 deletions src/Gameboard.Api/Data/Entities/SupportSettings.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;

namespace Gameboard.Api.Data;

public class SupportSettings : IEntity
{
public string Id { get; set; }
public ICollection<SupportSettingsAutoTag> AutoTags { get; set; } = [];
public string AutoTagPracticeTicketsWith { get; set; }
public string SupportPageGreeting { get; set; }
public DateTimeOffset UpdatedOn { get; set; }
Expand Down
15 changes: 15 additions & 0 deletions src/Gameboard.Api/Data/Entities/SupportSettingsAutoTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace Gameboard.Api.Data;

public class SupportSettingsAutoTag : IEntity
{
public string Id { get; set; }
public required SupportSettingsAutoTagConditionType ConditionType { get; set; }
public required string ConditionValue { get; set; }
public string Description { get; set; }
public required bool IsEnabled { get; set; }
public required string Tag { get; set; }

// navigation/modelfixup
public required string SupportSettingsId { get; set; }
public SupportSettings SupportSettings { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Gameboard.Api.Data;

public enum SupportSettingsAutoTagConditionType
{
ChallengeSpecId,
GameId,
PlayerMode,
SponsorId
}
24 changes: 23 additions & 1 deletion src/Gameboard.Api/Data/GameboardDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,28 @@ protected override void OnModelCreating(ModelBuilder builder)
.HasOne(b => b.UpdatedByUser)
.WithOne(u => u.UpdatedSupportSettings)
.HasForeignKey<SupportSettings>(s => s.UpdatedByUserId)
.OnDelete(DeleteBehavior.SetNull)
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
});

builder.Entity<SupportSettingsAutoTag>(b =>
{
b.HasKey(b => b.Id);
b
.Property(b => b.Tag)
.IsRequired()
.HasStandardNameLength();

b
.Property(b => b.ConditionValue)
.IsRequired()
.HasStandardGuidLength();

b
.HasOne(b => b.SupportSettings)
.WithMany(s => s.AutoTags)
.HasForeignKey(s => s.SupportSettingsId)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});

Expand Down Expand Up @@ -445,6 +466,7 @@ protected override void OnModelCreating(ModelBuilder builder)
public DbSet<Player> Players { get; set; }
public DbSet<PublishedCertificate> PublishedCertificate { get; set; }
public DbSet<Sponsor> Sponsors { get; set; }
public DbSet<SupportSettingsAutoTag> SupportSettingsAutoTags { get; set; }
public DbSet<SystemNotification> SystemNotifications { get; set; }
public DbSet<SystemNotificationInteraction> SystemNotificationInteractions { get; set; }
public DbSet<Ticket> Tickets { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,10 @@

namespace Gameboard.Api.Data;

public sealed class SlowCommandLogInterceptor : DbCommandInterceptor
public sealed class SlowCommandLogInterceptor(ILoggerFactory loggerFactory) : DbCommandInterceptor
{
private static readonly int DURATION_THRESHOLD_MS = 1500;
private readonly ILogger<SlowCommandLogInterceptor> _logger;

public SlowCommandLogInterceptor(ILoggerFactory loggerFactory)
{
_logger = loggerFactory.CreateLogger<SlowCommandLogInterceptor>();
}
private readonly ILogger<SlowCommandLogInterceptor> _logger = loggerFactory.CreateLogger<SlowCommandLogInterceptor>();

public override ValueTask<DbDataReader> ReaderExecutedAsync(DbCommand command, CommandExecutedEventData eventData, DbDataReader result, CancellationToken cancellationToken = default)
{
Expand Down
Loading

0 comments on commit 2f227a8

Please sign in to comment.