0
0

Compare commits

...

3 Commits

Author SHA1 Message Date
2a759b8d39 Update sql script
All checks were successful
Test API / build (push) Successful in 2m48s
2024-01-23 23:30:48 +03:00
3580e84f53 Remove RAUTITAN from tests 2024-01-23 23:30:48 +03:00
709d58aa8b Add index to DB 2024-01-23 23:30:47 +03:00
11 changed files with 47 additions and 24 deletions

View File

@ -14,12 +14,14 @@ CREATE TABLE "Products" (
"ProductLines" text[] NOT NULL,
"IsOnWarehouse" boolean NOT NULL,
"ProductMeasure" integer NOT NULL,
"DeliveryMakeUp" double precision NULL,
"DeliveryMakeUp" double precision,
"Price" numeric NOT NULL,
CONSTRAINT "PK_Products" PRIMARY KEY ("Id")
);
CREATE INDEX "IX_Products_Name" ON "Products" USING GIN (to_tsvector('russian', "Name"));
INSERT INTO "__EFMigrationsHistory" ("MigrationId", "ProductVersion")
VALUES ('20230511043408_Init', '7.0.5');
VALUES ('20240117210635_Init', '8.0.0');
COMMIT;

View File

@ -13,8 +13,8 @@ public class RautitanFittingsTests : ProductQueryModifierTests
public void SupportingClipTest(string query, string modified)
=> Execute(productType: "Желоб", query, modified);
[TestCase("Тройник 20-16-16", "Тройник RAUTITAN -PLATINUM 20-16-16")]
[TestCase("Тройник 20x16x16", "Тройник RAUTITAN -PLATINUM 20-16-16")]
[TestCase("Тройник 20-16-16", "Тройник -PLATINUM 20-16-16")]
[TestCase("Тройник 20x16x16", "Тройник -PLATINUM 20-16-16")]
public void TPieceTest(string query, string modified)
=> Execute(productType: "Тройник RAUTITAN", query, modified);
@ -30,7 +30,7 @@ public class RautitanFittingsTests : ProductQueryModifierTests
public void AdapterInternalTest(string query, string modified)
=> Execute(productType: "Переходник на внутреннюю резьбу", query, modified);
[TestCase("Угольник 90°, 40 PX", "Угольник RAUTITAN -PLATINUM 90 40")]
[TestCase("Угольник 90°, 40 PX", "Угольник -PLATINUM 90 40")]
public void ElbowTest(string query, string modified)
=> Execute(productType: "Угольник RAUTITAN", query, modified);
@ -47,12 +47,12 @@ public class RautitanFittingsTests : ProductQueryModifierTests
public void ScrewcapElbowTest(string query, string modified)
=> Execute(productType: "Угольник с накидной гайкой", query, modified);
[TestCase("Тройник с внутр. резьбой на боков. проходе 25-Rp 1/2-25 RX+", "Тройник RAUTITAN с внутр. резьбой на боков. проходе 25-Rp 1/2-25")]
[TestCase("Тройник настенный с внутренней резьбой 16-Rp1/2-16 RX+", "Тройник RAUTITAN настенный с внутренней резьбой 16-Rp1/2-16")]
[TestCase("Тройник с внутр. резьбой на боков. проходе 25-Rp 1/2-25 RX+", "Тройник с внутр. резьбой на боков. проходе 25-Rp 1/2-25")]
[TestCase("Тройник настенный с внутренней резьбой 16-Rp1/2-16 RX+", "Тройник настенный с внутренней резьбой 16-Rp1/2-16")]
public void ThreadTPieceInternalTest(string query, string modified)
=> Execute(productType: "Тройник RAUTITAN резьбовой внутренний", query, modified);
[TestCase("Тройник RAUTITAN RX+ с наружной резьбой 20-20-R 3/4", "Тройник RAUTITAN с наружной резьбой 20-20-R 3/4")]
[TestCase("Тройник RAUTITAN RX+ с наружной резьбой 20-20-R 3/4", "Тройник с наружной резьбой 20-20-R 3/4")]
public void ThreadTPieceExternalTest(string query, string modified)
=> Execute(productType: "Тройник RAUTITAN резьбовой наружный", query, modified);

View File

@ -23,9 +23,9 @@ namespace RhSolutions.Api.Controllers
public IAsyncEnumerable<Product> SearchProducts([FromQuery] string query)
{
return context.Products
.Where(p => EF.Functions.ToTsVector(
"russian", string.Join(' ', new[] { p.Name, string.Join(' ', p.ProductLines)}))
.Where(p => EF.Functions.ToTsVector("russian", p.Name)
.Matches(EF.Functions.WebSearchToTsQuery("russian", query)))
.Where(p => p.ProductLines.Contains("RAUTITAN"))
.OrderByDescending(p => p.IsOnWarehouse)
.AsAsyncEnumerable();
}

View File

@ -13,7 +13,7 @@ using RhSolutions.Models;
namespace RhSolutions.Api.Migrations
{
[DbContext(typeof(RhSolutionsContext))]
[Migration("20230511043408_Init")]
[Migration("20240117210635_Init")]
partial class Init
{
/// <inheritdoc />
@ -21,7 +21,7 @@ namespace RhSolutions.Api.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@ -34,7 +34,7 @@ namespace RhSolutions.Api.Migrations
b.Property<double?>("DeliveryMakeUp")
.HasColumnType("double precision");
b.Property<List<string>>("DeprecatedSkus")
b.Property<string[]>("DeprecatedSkus")
.IsRequired()
.HasColumnType("text[]");
@ -61,6 +61,11 @@ namespace RhSolutions.Api.Migrations
b.HasKey("Id");
b.HasIndex("Name")
.HasAnnotation("Npgsql:TsVectorConfig", "russian");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Name"), "GIN");
b.ToTable("Products");
});
#pragma warning restore 612, 618

View File

@ -18,7 +18,7 @@ namespace RhSolutions.Api.Migrations
Id = table.Column<string>(type: "text", nullable: false),
Name = table.Column<string>(type: "text", nullable: false),
ProductSku = table.Column<string>(type: "text", nullable: false),
DeprecatedSkus = table.Column<List<string>>(type: "text[]", nullable: false),
DeprecatedSkus = table.Column<string[]>(type: "text[]", nullable: false),
ProductLines = table.Column<List<string>>(type: "text[]", nullable: false),
IsOnWarehouse = table.Column<bool>(type: "boolean", nullable: false),
ProductMeasure = table.Column<int>(type: "integer", nullable: false),
@ -29,6 +29,13 @@ namespace RhSolutions.Api.Migrations
{
table.PrimaryKey("PK_Products", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Products_Name",
table: "Products",
column: "Name")
.Annotation("Npgsql:IndexMethod", "GIN")
.Annotation("Npgsql:TsVectorConfig", "russian");
}
/// <inheritdoc />

View File

@ -18,7 +18,7 @@ namespace RhSolutions.Api.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.5")
.HasAnnotation("ProductVersion", "8.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
@ -31,7 +31,7 @@ namespace RhSolutions.Api.Migrations
b.Property<double?>("DeliveryMakeUp")
.HasColumnType("double precision");
b.Property<List<string>>("DeprecatedSkus")
b.Property<string[]>("DeprecatedSkus")
.IsRequired()
.HasColumnType("text[]");
@ -58,6 +58,11 @@ namespace RhSolutions.Api.Migrations
b.HasKey("Id");
b.HasIndex("Name")
.HasAnnotation("Npgsql:TsVectorConfig", "russian");
NpgsqlIndexBuilderExtensions.HasMethod(b.HasIndex("Name"), "GIN");
b.ToTable("Products");
});
#pragma warning restore 612, 618

View File

@ -18,5 +18,9 @@ public class RhSolutionsContext : DbContext
.PrimitiveCollection(e => e.DeprecatedSkus)
.ElementType()
.HasConversion(typeof(SkuConverter));
}
builder.Entity<Product>()
.HasIndex(b => new { b.Name })
.HasMethod("GIN")
.IsTsVectorExpressionIndex("russian");
}
}

View File

@ -2,7 +2,7 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
public class Elbow : DrinkingWaterHeatingFitting
{
protected override string _title { get; } = "Угольник RAUTITAN -PLATINUM";
protected override string _title { get; } = "Угольник -PLATINUM";
public override bool TryQueryModify(string input, out string output)
{

View File

@ -2,7 +2,7 @@
public class TPiece : DrinkingWaterHeatingFitting
{
protected override string _title => "Тройник RAUTITAN -PLATINUM";
protected override string _title => "Тройник -PLATINUM";
public override bool TryQueryModify(string input, out string output)
{

View File

@ -4,7 +4,7 @@ namespace RhSolutions.QueryModifiers.DrinkingWaterHeatingFittings;
public class ThreadTPieceExternal : DrinkingWaterHeatingFitting
{
protected override string _title => "Тройник RAUTITAN с наружной резьбой";
protected override string _title => "Тройник с наружной резьбой";
public override bool TryQueryModify(string input, out string output)
{

View File

@ -18,22 +18,22 @@ public class ThreadTPieceInternal : DrinkingWaterHeatingFitting
{
if (diameters[0] < 25)
{
output = $"Тройник RAUTITAN настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[0]}";
output = $"Тройник настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[0]}";
}
else
{
output = $"Тройник RAUTITAN с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[0]}";
output = $"Тройник с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[0]}";
}
}
else
{
if (diameters[0] < 25)
{
output = $"Тройник RAUTITAN настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[1]}";
output = $"Тройник настенный с внутренней резьбой {diameters[0]}-Rp{thread}-{diameters[1]}";
}
else
{
output = $"Тройник RAUTITAN с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[1]}";
output = $"Тройник с внутр. резьбой на боков. проходе {diameters[0]}-Rp {thread}-{diameters[1]}";
}
}
return true;