Skip to content

Commit

Permalink
Make player search more accurate
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackburn29 committed Jan 15, 2024
1 parent a27fc09 commit 498fc83
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,25 @@ public MigratePlayersCommand(FragmentContext database, OldFragmentContext oldDat

public override Task<int> ExecuteAsync(CommandContext context, Settings settings)
{
/*
AnsiConsole.Progress()
.AutoClear(false)
.Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new RemainingTimeColumn(),
new SpinnerColumn())
.Start(MigratePlayerRecords);
*/

AnsiConsole.Progress()
.AutoClear(false)
.Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new RemainingTimeColumn(),
new SpinnerColumn())
.Start(MigrateCharacterRecords);

/*
AnsiConsole.Progress()
.AutoClear(false)
.Columns(new TaskDescriptionColumn(), new ProgressBarColumn(), new PercentageColumn(), new RemainingTimeColumn(),
new SpinnerColumn())
.Start(MigrateCharacterStatHistory);
*/


return Task.FromResult(0);
Expand Down
2 changes: 1 addition & 1 deletion src/Fragment.NetSlum.Core/Fragment.NetSlum.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Aliases>IPNetwork2</Aliases>
</PackageReference>
<PackageReference Include="MediatR" Version="12.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0-beta.2" />
Expand Down
4 changes: 4 additions & 0 deletions src/Fragment.NetSlum.Persistence/FragmentContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
// Use snake_cased table/column names to keep things consistent with the old database layout
optionsBuilder
.UseSnakeCaseNamingConvention();

#if (DEBUG)
optionsBuilder.EnableSensitiveDataLogging();
#endif
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
Expand Down
17 changes: 10 additions & 7 deletions src/Fragment.NetSlum.Server/Api/Controllers/PlayersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using AutoMapper;
using Fragment.NetSlum.Networking.Sessions;
using Fragment.NetSlum.Persistence;
using Fragment.NetSlum.Persistence.Entities;
using Fragment.NetSlum.Persistence.Extensions;
using Fragment.NetSlum.Server.Api.Models;
using Fragment.NetSlum.TcpServer;
Expand Down Expand Up @@ -33,20 +34,22 @@ public PlayersController(ITcpServer gameServer, FragmentContext database, IMappe
[HttpGet]
public PagedResult<PlayerInfo> GetAllPlayers(int page = 1, int pageSize = 50, string? characterName = null)
{
var guilds = _database.Characters
IQueryable<Character> characters = _database.Characters
.AsNoTracking()
.Include(g => g.CharacterStats)
.OrderBy(g => g.Id)
.Paginate(page, pageSize);
.Include(g => g.CharacterStats);

if (!string.IsNullOrWhiteSpace(characterName))
{
guilds = guilds.Where(c => c.CharacterName.Contains(characterName));
characters = characters.Where(c =>
EF.Functions.Collate(
EF.Functions.Like(c.CharacterName, $"%{characterName}%"), $"utf8mb4_0900_ai_ci"));
}

var guildCount = _database.Guilds.Count();
var characterCount = characters.Count();

return new PagedResult<PlayerInfo>(page, pageSize, guildCount, _mapper.Map<List<PlayerInfo>>(guilds.ToList()));
var results = characters.Paginate(page, pageSize);

return new PagedResult<PlayerInfo>(page, pageSize, characterCount, _mapper.Map<List<PlayerInfo>>(results));
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Fragment.NetSlum.Server/Fragment.NetSlum.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Haukcode.HighResolutionTimer" Version="1.1.0" />
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.5.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Include="NSwag.AspNetCore" Version="14.0.0" />
<PackageReference Include="NSwag.AspNetCore" Version="14.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="5.0.1" />
Expand Down

0 comments on commit 498fc83

Please sign in to comment.