#23 some caching fields for probable future use of Ganjoor Structures
This commit is contained in:
parent
0b3a30d55d
commit
e5e8ac02b0
@ -69,7 +69,13 @@ namespace RMuseum.DbContext
|
||||
.HasIndex(t => t.FriendlyUrl);
|
||||
|
||||
builder.Entity<RTagValue>()
|
||||
.HasIndex(t => t.FriendlyUrl);
|
||||
.HasIndex(t => t.FriendlyUrl);
|
||||
|
||||
builder.Entity<GanjoorCat>()
|
||||
.HasIndex(c => c.FullUrl);
|
||||
|
||||
builder.Entity<GanjoorPoem>()
|
||||
.HasIndex(c => c.FullUrl);
|
||||
|
||||
}
|
||||
|
||||
|
||||
1553
RMuseum/Migrations/20201023091130_GanjoorCachingFields.Designer.cs
generated
Normal file
1553
RMuseum/Migrations/20201023091130_GanjoorCachingFields.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
49
RMuseum/Migrations/20201023091130_GanjoorCachingFields.cs
Normal file
49
RMuseum/Migrations/20201023091130_GanjoorCachingFields.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace RMuseum.Migrations
|
||||
{
|
||||
public partial class GanjoorCachingFields : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CachedContent",
|
||||
table: "GanjoorPoems",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorPoems",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "CachedContent",
|
||||
table: "GanjoorCategories",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorCategories",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CachedContent",
|
||||
table: "GanjoorPoems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorPoems");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CachedContent",
|
||||
table: "GanjoorCategories");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorCategories");
|
||||
}
|
||||
}
|
||||
}
|
||||
1557
RMuseum/Migrations/20201023091559_GanjoorIndices.Designer.cs
generated
Normal file
1557
RMuseum/Migrations/20201023091559_GanjoorIndices.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
63
RMuseum/Migrations/20201023091559_GanjoorIndices.cs
Normal file
63
RMuseum/Migrations/20201023091559_GanjoorIndices.cs
Normal file
@ -0,0 +1,63 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace RMuseum.Migrations
|
||||
{
|
||||
public partial class GanjoorIndices : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorPoems",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(max)",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorCategories",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "nvarchar(max)",
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GanjoorPoems_FullUrl",
|
||||
table: "GanjoorPoems",
|
||||
column: "FullUrl");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GanjoorCategories_FullUrl",
|
||||
table: "GanjoorCategories",
|
||||
column: "FullUrl");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_GanjoorPoems_FullUrl",
|
||||
table: "GanjoorPoems");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_GanjoorCategories_FullUrl",
|
||||
table: "GanjoorCategories");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorPoems",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldNullable: true);
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "FullUrl",
|
||||
table: "GanjoorCategories",
|
||||
type: "nvarchar(max)",
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -341,6 +341,12 @@ namespace RMuseum.Migrations
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CachedContent")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FullUrl")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<int?>("ParentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
@ -355,6 +361,8 @@ namespace RMuseum.Migrations
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("FullUrl");
|
||||
|
||||
b.HasIndex("ParentId");
|
||||
|
||||
b.HasIndex("PoetId");
|
||||
@ -367,12 +375,18 @@ namespace RMuseum.Migrations
|
||||
b.Property<int>("Id")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("CachedContent")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("CatId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("FullTitle")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("FullUrl")
|
||||
.HasColumnType("nvarchar(450)");
|
||||
|
||||
b.Property<string>("Title")
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
@ -383,6 +397,8 @@ namespace RMuseum.Migrations
|
||||
|
||||
b.HasIndex("CatId");
|
||||
|
||||
b.HasIndex("FullUrl");
|
||||
|
||||
b.ToTable("GanjoorPoems");
|
||||
});
|
||||
|
||||
|
||||
@ -43,5 +43,15 @@ namespace RMuseum.Models.Ganjoor
|
||||
/// url => slug
|
||||
/// </summary>
|
||||
public string UrlSlug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sample: /hafez/ghazal
|
||||
/// </summary>
|
||||
public string FullUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cached Content to be used on UI
|
||||
/// </summary>
|
||||
public string CachedContent { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,5 +38,15 @@ namespace RMuseum.Models.Ganjoor
|
||||
/// url => slug
|
||||
/// </summary>
|
||||
public string UrlSlug { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// sample: /hafez/ghazal/sh1
|
||||
/// </summary>
|
||||
public string FullUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cached Content to be used on UI
|
||||
/// </summary>
|
||||
public string CachedContent { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -2802,6 +2802,16 @@
|
||||
url => slug
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorCat.FullUrl">
|
||||
<summary>
|
||||
sample: /hafez/ghazal
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorCat.CachedContent">
|
||||
<summary>
|
||||
Cached Content to be used on UI
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoem">
|
||||
<summary>
|
||||
Ganjoor Poem
|
||||
@ -2837,6 +2847,16 @@
|
||||
url => slug
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoem.FullUrl">
|
||||
<summary>
|
||||
sample: /hafez/ghazal/sh1
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:RMuseum.Models.Ganjoor.GanjoorPoem.CachedContent">
|
||||
<summary>
|
||||
Cached Content to be used on UI
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:RMuseum.Models.Ganjoor.GanjoorPoet">
|
||||
<summary>
|
||||
Ganjoor Poet
|
||||
|
||||
@ -54,7 +54,7 @@ namespace RMuseum.Services.Implementation
|
||||
command.CommandText =
|
||||
$"INSERT INTO GanjoorPoets (Id, Name, Description) VALUES (${poet.id}, N'{poet.name}', N'{poet.description}')";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
await _ImportSQLiteCatChildren(command, dapper, poetId, 0, poet.name);
|
||||
await _ImportSQLiteCatChildren(command, dapper, poetId, 0, poet.name, "");
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
}
|
||||
@ -79,20 +79,21 @@ namespace RMuseum.Services.Implementation
|
||||
|
||||
|
||||
|
||||
private async Task _ImportSQLiteCatChildren(DbCommand command, IDbConnection dapper, int poetId, int catId, string itemFullTitle)
|
||||
private async Task _ImportSQLiteCatChildren(DbCommand command, IDbConnection dapper, int poetId, int catId, string itemFullTitle, string itemFullSlug)
|
||||
{
|
||||
|
||||
foreach(var cat in await dapper.QueryAsync($"SELECT * FROM cat WHERE poet_id = {poetId} AND parent_id = {catId} ORDER BY id"))
|
||||
{
|
||||
if(catId == 0)
|
||||
|
||||
if (catId == 0)
|
||||
{
|
||||
command.CommandText =
|
||||
$"INSERT INTO GanjoorCategories (Id, PoetId, Title, UrlSlug) VALUES (${cat.id}, {poetId}, N'{cat.text}', '{ _ExtractUrlSlug(cat.url)}')";
|
||||
$"INSERT INTO GanjoorCategories (Id, PoetId, Title, UrlSlug, FullUrl) VALUES (${cat.id}, {poetId}, N'{cat.text}', '{ _ExtractUrlSlug(cat.url)}', '{itemFullSlug}/{ _ExtractUrlSlug(cat.url)}')";
|
||||
}
|
||||
else
|
||||
{
|
||||
command.CommandText =
|
||||
$"INSERT INTO GanjoorCategories (Id, PoetId, Title, ParentId, UrlSlug) VALUES (${cat.id}, {poetId}, N'{cat.text}', {catId}, '{ _ExtractUrlSlug(cat.url)}')";
|
||||
$"INSERT INTO GanjoorCategories (Id, PoetId, Title, ParentId, UrlSlug, FullUrl) VALUES (${cat.id}, {poetId}, N'{cat.text}', {catId}, '{ _ExtractUrlSlug(cat.url)}', '{itemFullSlug}/{ _ExtractUrlSlug(cat.url)}')";
|
||||
}
|
||||
|
||||
await command.ExecuteNonQueryAsync();
|
||||
@ -101,7 +102,7 @@ namespace RMuseum.Services.Implementation
|
||||
foreach (var poem in await dapper.QueryAsync($"SELECT * FROM poem WHERE cat_id = {cat.id} ORDER BY id"))
|
||||
{
|
||||
command.CommandText =
|
||||
$"INSERT INTO GanjoorPoems (Id, CatId, Title, UrlSlug, FullTitle) VALUES (${poem.id}, {cat.id}, N'{poem.title}', '{ _ExtractUrlSlug(poem.url)}', N'{$"{itemFullTitle} » {cat.text} » {poem.title}"}')";
|
||||
$"INSERT INTO GanjoorPoems (Id, CatId, Title, UrlSlug, FullTitle, FullUrl) VALUES (${poem.id}, {cat.id}, N'{poem.title}', '{ _ExtractUrlSlug(poem.url)}', N'{$"{itemFullTitle} » {cat.text} » {poem.title}"}', '{itemFullSlug}/{ _ExtractUrlSlug(cat.url)}/{_ExtractUrlSlug(poem.url)}')";
|
||||
await command.ExecuteNonQueryAsync();
|
||||
|
||||
foreach (var verse in await dapper.QueryAsync($"SELECT * FROM verse WHERE poem_id = {poem.id} ORDER BY vorder"))
|
||||
@ -114,7 +115,7 @@ namespace RMuseum.Services.Implementation
|
||||
}
|
||||
|
||||
|
||||
await _ImportSQLiteCatChildren(command, dapper, poetId, (int)cat.id, $"{itemFullTitle} » {cat.text}");
|
||||
await _ImportSQLiteCatChildren(command, dapper, poetId, (int)cat.id, $"{itemFullTitle} » {cat.text}", $"{itemFullSlug}/{ _ExtractUrlSlug(cat.url)}");
|
||||
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user