Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using ClemBot.Api.Common;
using ClemBot.Api.Data.Contexts;
using Microsoft.EntityFrameworkCore;
using NodaTime;

namespace ClemBot.Api.Core.Features.Guilds.Bot;

Expand All @@ -25,6 +26,9 @@ public record Score
public ulong HighScore { get; init; }

public ulong UserId { get; init; }
public LocalDateTime TimeOccurred { get; init; }
public ulong? MessageId { get; init; }
public ulong? ChannelId { get; init; }
}

public class QueryHandler : IRequestHandler<Query, QueryResult<Model>>
Expand All @@ -43,7 +47,7 @@ public async Task<QueryResult<Model>> Handle(Query request, CancellationToken ca
.QueryIfElse(() => request.Leader,
q => q.OrderByDescending(y => y.Score),
q => q.OrderBy(y => y.Score))
.Select(z => new { z.Score, z.UserId })
.Select(z => new { z.Score, z.UserId, z.Time, z.MessageId, z.ChannelId })
.Take(request.Limit)
.ToListAsync();

Expand All @@ -52,7 +56,10 @@ public async Task<QueryResult<Model>> Handle(Query request, CancellationToken ca
Scores = scores.Select(x => new Score
{
HighScore = x.Score,
UserId = x.UserId
UserId = x.UserId,
TimeOccurred = x.Time,
MessageId = x.MessageId,
ChannelId = x.ChannelId
})
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ public class Command : IRequest<QueryResult<int>>
public ulong GuildId { get; set; }

public ulong UserId { get; set; }

public ulong MessageId { get; set; }

public ulong ChannelId { get; set; }
}

public record Handler(ClemBotContext _context, IMediator _mediator)
Expand All @@ -32,6 +36,8 @@ public async Task<QueryResult<int>> Handle(Command request, CancellationToken ca
GuildId = request.GuildId,
UserId = request.UserId,
Time = SystemClock.Instance.InZone(DateTimeZone.Utc).GetCurrentLocalDateTime(),
MessageId = request.MessageId,
ChannelId = request.ChannelId
};

_context.SlotScores.Add(score);
Expand Down
Loading