fix: Fixed UserId patron table error

fix: Added au and kz countries as en and kz languages respectively
fix: Strikeout is thinner now on plants
This commit is contained in:
Kwoth
2024-11-03 08:24:00 +00:00
parent 32fc8b6e03
commit b6b6b4e19e
13 changed files with 7076 additions and 58 deletions

View File

@@ -2,6 +2,8 @@
Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o Mostly based on [keepachangelog](https://keepachangelog.com/en/1.0.0/) except date format. a-c-f-r-o
## [5.1.19]
## [5.1.18] - 02.11.2024 ## [5.1.18] - 02.11.2024
### Added ### Added

View File

@@ -15,6 +15,17 @@ service GrpcXp {
rpc AddReward(AddRewardRequest) returns (AddRewardReply); rpc AddReward(AddRewardRequest) returns (AddRewardReply);
rpc DeleteReward(DeleteRewardRequest) returns (DeleteRewardReply); rpc DeleteReward(DeleteRewardRequest) returns (DeleteRewardReply);
rpc SetServerExclusion(SetServerExclusionRequest) returns (SetServerExclusionReply);
}
message SetServerExclusionRequest {
uint64 guildId = 1;
bool serverExcluded = 2;
}
message SetServerExclusionReply {
bool success = 1;
} }
message GetXpLbRequest { message GetXpLbRequest {
@@ -32,7 +43,8 @@ message XpLbUserReply {
string username = 2; string username = 2;
int64 xp = 3; int64 xp = 3;
int64 level = 4; int64 level = 4;
string avatar = 5; int64 levelPercent = 5;
string avatar = 6;
} }
message ResetUserXpRequest { message ResetUserXpRequest {

View File

@@ -3,6 +3,7 @@ namespace NadekoBot.Db.Models;
public class PatronUser public class PatronUser
{ {
public int Id { get; set; }
public string UniquePlatformUserId { get; set; } public string UniquePlatformUserId { get; set; }
public ulong UserId { get; set; } public ulong UserId { get; set; }
public int AmountCents { get; set; } public int AmountCents { get; set; }

View File

@@ -618,7 +618,7 @@ public abstract class NadekoContext : DbContext
modelBuilder.Entity<PatronUser>(pu => modelBuilder.Entity<PatronUser>(pu =>
{ {
pu.HasIndex(x => x.UniquePlatformUserId).IsUnique(); pu.HasIndex(x => x.UniquePlatformUserId).IsUnique();
pu.HasKey(x => x.UserId); pu.HasIndex(x => x.UserId).IsUnique(false);
}); });
// quotes are per user id // quotes are per user id

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace NadekoBot.Migrations.PostgreSql
{
/// <inheritdoc />
public partial class patronfix : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "pk_patrons",
table: "patrons");
migrationBuilder.AddColumn<int>(
name: "id",
table: "patrons",
type: "integer",
nullable: false,
defaultValue: 0)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn);
migrationBuilder.AddPrimaryKey(
name: "pk_patrons",
table: "patrons",
column: "id");
migrationBuilder.CreateIndex(
name: "ix_patrons_userid",
table: "patrons",
column: "userid");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "pk_patrons",
table: "patrons");
migrationBuilder.DropIndex(
name: "ix_patrons_userid",
table: "patrons");
migrationBuilder.DropColumn(
name: "id",
table: "patrons");
migrationBuilder.AddPrimaryKey(
name: "pk_patrons",
table: "patrons",
column: "userid");
}
}
}

View File

@@ -1753,10 +1753,12 @@ namespace NadekoBot.Migrations.PostgreSql
modelBuilder.Entity("NadekoBot.Db.Models.PatronUser", b => modelBuilder.Entity("NadekoBot.Db.Models.PatronUser", b =>
{ {
b.Property<decimal>("UserId") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("numeric(20,0)") .HasColumnType("integer")
.HasColumnName("userid"); .HasColumnName("id");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("AmountCents") b.Property<int>("AmountCents")
.HasColumnType("integer") .HasColumnType("integer")
@@ -1770,17 +1772,24 @@ namespace NadekoBot.Migrations.PostgreSql
.HasColumnType("text") .HasColumnType("text")
.HasColumnName("uniqueplatformuserid"); .HasColumnName("uniqueplatformuserid");
b.Property<decimal>("UserId")
.HasColumnType("numeric(20,0)")
.HasColumnName("userid");
b.Property<DateTime>("ValidThru") b.Property<DateTime>("ValidThru")
.HasColumnType("timestamp without time zone") .HasColumnType("timestamp without time zone")
.HasColumnName("validthru"); .HasColumnName("validthru");
b.HasKey("UserId") b.HasKey("Id")
.HasName("pk_patrons"); .HasName("pk_patrons");
b.HasIndex("UniquePlatformUserId") b.HasIndex("UniquePlatformUserId")
.IsUnique() .IsUnique()
.HasDatabaseName("ix_patrons_uniqueplatformuserid"); .HasDatabaseName("ix_patrons_uniqueplatformuserid");
b.HasIndex("UserId")
.HasDatabaseName("ix_patrons_userid");
b.ToTable("patrons", (string)null); b.ToTable("patrons", (string)null);
}); });

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,75 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace NadekoBot.Migrations
{
/// <inheritdoc />
public partial class patronfix : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Patrons",
table: "Patrons");
migrationBuilder.AlterColumn<ulong>(
name: "UserId",
table: "Patrons",
type: "INTEGER",
nullable: false,
oldClrType: typeof(ulong),
oldType: "INTEGER")
.OldAnnotation("Sqlite:Autoincrement", true);
migrationBuilder.AddColumn<int>(
name: "Id",
table: "Patrons",
type: "INTEGER",
nullable: false,
defaultValue: 0)
.Annotation("Sqlite:Autoincrement", true);
migrationBuilder.AddPrimaryKey(
name: "PK_Patrons",
table: "Patrons",
column: "Id");
migrationBuilder.CreateIndex(
name: "IX_Patrons_UserId",
table: "Patrons",
column: "UserId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_Patrons",
table: "Patrons");
migrationBuilder.DropIndex(
name: "IX_Patrons_UserId",
table: "Patrons");
migrationBuilder.DropColumn(
name: "Id",
table: "Patrons");
migrationBuilder.AlterColumn<ulong>(
name: "UserId",
table: "Patrons",
type: "INTEGER",
nullable: false,
oldClrType: typeof(ulong),
oldType: "INTEGER")
.Annotation("Sqlite:Autoincrement", true);
migrationBuilder.AddPrimaryKey(
name: "PK_Patrons",
table: "Patrons",
column: "UserId");
}
}
}

View File

@@ -1307,7 +1307,7 @@ namespace NadekoBot.Migrations
modelBuilder.Entity("NadekoBot.Db.Models.PatronUser", b => modelBuilder.Entity("NadekoBot.Db.Models.PatronUser", b =>
{ {
b.Property<ulong>("UserId") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("INTEGER"); .HasColumnType("INTEGER");
@@ -1320,14 +1320,19 @@ namespace NadekoBot.Migrations
b.Property<string>("UniquePlatformUserId") b.Property<string>("UniquePlatformUserId")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.Property<ulong>("UserId")
.HasColumnType("INTEGER");
b.Property<DateTime>("ValidThru") b.Property<DateTime>("ValidThru")
.HasColumnType("TEXT"); .HasColumnType("TEXT");
b.HasKey("UserId"); b.HasKey("Id");
b.HasIndex("UniquePlatformUserId") b.HasIndex("UniquePlatformUserId")
.IsUnique(); .IsUnique();
b.HasIndex("UserId");
b.ToTable("Patrons"); b.ToTable("Patrons");
}); });

View File

@@ -169,7 +169,7 @@ public class PlantPickService : INService, IExecNoCommand
Start = 0, Start = 0,
End = pass.GetGraphemeCount(), End = pass.GetGraphemeCount(),
Font = font, Font = font,
StrikeoutPen = new SolidPen(Color.White, 5), StrikeoutPen = new SolidPen(Color.White, 3),
TextDecorations = TextDecorations.Strikeout TextDecorations = TextDecorations.Strikeout
}; };

View File

@@ -69,5 +69,8 @@ public partial class FlagTranslateService
YE ar YE ar
AL sq AL sq
AE ar AE ar
AU en
NZ en
KZ kz
"""; """;
} }

View File

@@ -67,12 +67,12 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, INService
}); });
rews = rews.Concat(roleRews.Select(x => new RewItemReply() rews = rews.Concat(roleRews.Select(x => new RewItemReply()
{ {
Level = x.Level, Level = x.Level,
Type = "Role", Type = x.Remove ? "RemoveRole" : "AddRole",
Value = guild.GetRole(x.RoleId)?.ToString() ?? x.RoleId.ToString() Value = guild.GetRole(x.RoleId)?.ToString() ?? x.RoleId.ToString()
})) }))
.OrderBy(x => x.Level); .OrderBy(x => x.Level);
reply.Rewards.AddRange(rews); reply.Rewards.AddRange(rews);
@@ -207,15 +207,15 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, INService
public override async Task<GetXpLbReply> GetXpLb(GetXpLbRequest request, ServerCallContext context) public override async Task<GetXpLbReply> GetXpLb(GetXpLbRequest request, ServerCallContext context)
{ {
if (request.Page < 0) if (request.Page < 1)
throw new RpcException(new Status(StatusCode.InvalidArgument, "Page must be greater than or equal to 0")); throw new RpcException(new Status(StatusCode.InvalidArgument, "Page must be greater than or equal to 1"));
var guild = _client.GetGuild(request.GuildId); var guild = _client.GetGuild(request.GuildId);
if (guild is null) if (guild is null)
throw new RpcException(new Status(StatusCode.NotFound, "Guild not found")); throw new RpcException(new Status(StatusCode.NotFound, "Guild not found"));
var data = await _xp.GetGuildUserXps(request.GuildId, request.Page); var data = await _xp.GetGuildUserXps(request.GuildId, request.Page - 1);
var total = await _xp.GetTotalGuildUsers(request.GuildId); var total = await _xp.GetTotalGuildUsers(request.GuildId);
var reply = new GetXpLbReply var reply = new GetXpLbReply
@@ -223,45 +223,60 @@ public class XpSvc : GrpcXp.GrpcXpBase, IGrpcSvc, INService
Total = total Total = total
}; };
reply.Users.AddRange(await data var users = await data
.Select(async x => .Select(async x =>
{ {
var user = guild.GetUser(x.UserId); var user = guild.GetUser(x.UserId);
if (user is null) if (user is null)
{ {
var du = await _duSvc.GetUserAsync(x.UserId); var du = await _duSvc.GetUserAsync(x.UserId);
if (du is null) if (du is null)
return new XpLbUserReply return new XpLbUserReply
{ {
UserId = x.UserId, UserId = x.UserId,
Avatar = string.Empty, Avatar = string.Empty,
Username = string.Empty, Username = string.Empty,
Xp = x.Xp, Xp = x.Xp,
Level = new LevelStats(x.Xp).Level Level = new LevelStats(x.Xp).Level
}; };
return new XpLbUserReply() return new XpLbUserReply()
{ {
UserId = x.UserId, UserId = x.UserId,
Avatar = du.RealAvatarUrl()?.ToString() ?? string.Empty, Avatar = du.RealAvatarUrl()?.ToString() ?? string.Empty,
Username = du.ToString() ?? string.Empty, Username = du.ToString() ?? string.Empty,
Xp = x.Xp, Xp = x.Xp,
Level = new LevelStats(x.Xp).Level Level = new LevelStats(x.Xp).Level
}; };
} }
return new XpLbUserReply return new XpLbUserReply
{ {
UserId = x.UserId, UserId = x.UserId,
Avatar = user?.GetAvatarUrl() ?? string.Empty, Avatar = user?.GetAvatarUrl() ?? string.Empty,
Username = user?.ToString() ?? string.Empty, Username = user?.ToString() ?? string.Empty,
Xp = x.Xp, Xp = x.Xp,
Level = new LevelStats(x.Xp).Level Level = new LevelStats(x.Xp).Level
}; };
}) })
.WhenAll()); .WhenAll();
reply.Users.AddRange(users);
return reply; return reply;
} }
public override async Task<SetServerExclusionReply> SetServerExclusion(
SetServerExclusionRequest request,
ServerCallContext context)
{
await Task.Yield();
var newValue = _xp.ToggleExcludeServer(request.GuildId);
return new()
{
Success = newValue
};
}
} }