Skip to content

Commit

Permalink
dragon limits
Browse files Browse the repository at this point in the history
  • Loading branch information
pavel-zhur committed Aug 19, 2024
1 parent 55b7d35 commit 5d33c2c
Show file tree
Hide file tree
Showing 13 changed files with 446 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ protected override (string? additionalBillingInfo, int? domainId) GetDialogConfi
return imagesUnavailableUntil;
}

protected override async Task<DateTime?> GetChatUnavailableUntil() => null;

Check warning on line 81 in OneShelf.OneDog/OneShelf.OneDog.Processor/Services/PipelineHandlers/AiDialogHandler.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

protected override string UnavailableUntilTemplate => throw new InvalidOperationException();

protected override async Task<(string? system, string? version, float? frequencyPenalty, float? presencePenalty, int? imagesVersion)> GetAiParameters()

Check warning on line 85 in OneShelf.OneDog/OneShelf.OneDog.Processor/Services/PipelineHandlers/AiDialogHandler.cs

View workflow job for this annotation

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
var system = _dogContext.Domain.SystemMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public DragonDatabase(DbContextOptions<DragonDatabase> options) : base(options)

public required DbSet<AiParameters> AiParameters { get; set; }

public required DbSet<Limit> Limits { get; set; }

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace OneShelf.OneDragon.Database.Migrations
{
/// <inheritdoc />
public partial class AddLimits : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<bool>(
name: "UseLimits",
table: "Users",
type: "bit",
nullable: false,
defaultValue: false);

migrationBuilder.CreateTable(
name: "Limits",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Images = table.Column<int>(type: "int", nullable: true),
Texts = table.Column<int>(type: "int", nullable: true),
Window = table.Column<long>(type: "bigint", nullable: false),
IsEnabled = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Limits", x => x.Id);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Limits");

migrationBuilder.DropColumn(
name: "UseLimits",
table: "Users");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,31 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("Interactions");
});

modelBuilder.Entity("OneShelf.OneDragon.Database.Model.Limit", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");

SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));

b.Property<int?>("Images")
.HasColumnType("int");

b.Property<bool>("IsEnabled")
.HasColumnType("bit");

b.Property<int?>("Texts")
.HasColumnType("int");

b.Property<long>("Window")
.HasColumnType("bigint");

b.HasKey("Id");

b.ToTable("Limits");
});

modelBuilder.Entity("OneShelf.OneDragon.Database.Model.Update", b =>
{
b.Property<int>("Id")
Expand Down Expand Up @@ -166,6 +191,9 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.IsRequired()
.HasColumnType("nvarchar(max)");

b.Property<bool>("UseLimits")
.HasColumnType("bit");

b.Property<string>("UserName")
.HasColumnType("nvarchar(max)");

Expand Down
17 changes: 17 additions & 0 deletions OneShelf.OneDragon/OneShelf.OneDragon.Database/Model/Limit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System.ComponentModel.DataAnnotations.Schema;

namespace OneShelf.OneDragon.Database.Model;

public class Limit
{
public int Id { get; set; }

public int? Images { get; set; }

public int? Texts { get; set; }

[Column(TypeName = "bigint")]
public required TimeSpan Window { get; set; }

public bool IsEnabled { get; set; }
}
2 changes: 2 additions & 0 deletions OneShelf.OneDragon/OneShelf.OneDragon.Database/Model/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ public class User
public string? UserName { get; set; }

public string? LanguageCode { get; set; }

public bool UseLimits { get; set; }
}
Loading

0 comments on commit 5d33c2c

Please sign in to comment.