#438 GanjoorCatViewModel + PaperSources

This commit is contained in:
Hamid Reza Mohammadi 2024-05-04 08:46:39 +03:30
parent b212ab96de
commit 38d6e40fec
7 changed files with 174 additions and 98 deletions

View File

@ -572,7 +572,7 @@ namespace RMuseum.DbContext
/// <summary>
/// paper sources
/// </summary>
public DbSet<PaperSource> PaperSources { get; set; }
public DbSet<GanjoorPaperSource> GanjoorPaperSources { get; set; }
}
}

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Http;
using RMuseum.Models.GanjoorIntegration;
using System;
using System.Collections.Generic;
@ -104,6 +105,11 @@ namespace RMuseum.Models.Ganjoor.ViewModels
/// </summary>
public ICollection<GanjoorPoemSummaryViewModel> Poems { get; set; }
/// <summary>
/// paper sources
/// </summary>
public ICollection<GanjoorPaperSource> PaperSources { get; set; }
/// <summary>
/// new image
/// </summary>

View File

@ -5,7 +5,7 @@ namespace RMuseum.Models.GanjoorIntegration
/// <summary>
/// Ganjoor Paper Source
/// </summary>
public class PaperSource
public class GanjoorPaperSource
{
/// <summary>
/// Id

View File

@ -2033,6 +2033,13 @@
<param name="textOriginal"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.ImportNaskbanGanjoorPoemMatchFindings(RSecurityBackend.Models.Auth.ViewModels.LoginViewModel)">
<summary>
import naskban ganjoor matchings
</summary>
<param name="loginViewModel"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Controllers.GanjoorController.DeletePoemRelatedNaskbanImagesByNaskbanUrlAsync(System.String)">
<summary>
delete poem related naskban images by url
@ -3508,7 +3515,7 @@
discover quoted q items
</summary>
</member>
<member name="P:RMuseum.DbContext.RMuseumDbContext.PaperSources">
<member name="P:RMuseum.DbContext.RMuseumDbContext.GanjoorPaperSources">
<summary>
paper sources
</summary>
@ -6492,6 +6499,86 @@
is text original source
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource">
<summary>
Ganjoor Paper Source
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.Id">
<summary>
Id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.GanjoorPoetId">
<summary>
poet id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.GanjoorCatId">
<summary>
cat id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.GanjoorCatFullTitle">
<summary>
cat full title
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.GanjoorCatFullUrl">
<summary>
cat full url
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.BookType">
<summary>
book type
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.BookFullUrl">
<summary>
book full url
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.NaskbanBookId">
<summary>
naskban book id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.BookFullTitle">
<summary>
book title
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.Description">
<summary>
description
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.IsTextOriginalSource">
<summary>
is the text original source for the category?
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.CoverThumbnailImageUrl">
<summary>
cover thumbnail image url
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.MatchPercent">
<summary>
match percent
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.HumanReviewed">
<summary>
reviewed by a human
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.GanjoorPaperSource.OrderIndicator">
<summary>
position in sorting
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorIntegration.LinkType">
<summary>
Link Type
@ -6522,86 +6609,6 @@
Naskban
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorIntegration.PaperSource">
<summary>
Ganjoor Paper Source
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.Id">
<summary>
Id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.GanjoorPoetId">
<summary>
poet id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.GanjoorCatId">
<summary>
cat id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.GanjoorCatFullTitle">
<summary>
cat full title
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.GanjoorCatFullUrl">
<summary>
cat full url
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.BookType">
<summary>
book type
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.BookFullUrl">
<summary>
book full url
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.NaskbanBookId">
<summary>
naskban book id
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.BookFullTitle">
<summary>
book title
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.Description">
<summary>
description
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.IsTextOriginalSource">
<summary>
is the text original source for the category?
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.CoverThumbnailImageUrl">
<summary>
cover thumbnail image url
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.MatchPercent">
<summary>
match percent
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.HumanReviewed">
<summary>
reviewed by a human
</summary>
</member>
<member name="P:RMuseum.Models.GanjoorIntegration.PaperSource.OrderIndicator">
<summary>
position in sorting
</summary>
</member>
<member name="T:RMuseum.Models.GanjoorIntegration.PDFGanjoorLink">
<summary>
PDFBook Ganjoor Link
@ -10293,6 +10300,11 @@
poems
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCatViewModel.PaperSources">
<summary>
paper sources
</summary>
</member>
<member name="P:RMuseum.Models.Ganjoor.ViewModels.GanjoorCatViewModel.NewImage">
<summary>
new image
@ -15001,22 +15013,24 @@
<param name="url"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetCatById(System.Int32,System.Boolean,System.Boolean)">
<member name="M:RMuseum.Services.IGanjoorService.GetCatById(System.Int32,System.Boolean,System.Boolean,System.Boolean)">
<summary>
get cat by id
</summary>
<param name="id"></param>
<param name="poems"></param>
<param name="mainSections"></param>
<param name="paperSources"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetCatByUrl(System.String,System.Boolean,System.Boolean)">
<member name="M:RMuseum.Services.IGanjoorService.GetCatByUrl(System.String,System.Boolean,System.Boolean,System.Boolean)">
<summary>
get cat by url
</summary>
<param name="url"></param>
<param name="poems"></param>
<param name="mainSections"></param>
<param name="paperSources"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.SetCategoryExtraInfo(System.Int32,System.String,System.Nullable{System.Guid},System.Boolean,System.String)">
@ -16163,6 +16177,20 @@
<param name="naskbanUserName"></param>
<param name="naskbanPassword"></param>
</member>
<member name="M:RMuseum.Services.IGanjoorService.ImportNaskbanGanjoorPoemMatchFindings(System.String,System.String)">
<summary>
import naskban ganjoor matchings
</summary>
<param name="naskbanUserName"></param>
<param name="naskbanPassword"></param>
</member>
<member name="M:RMuseum.Services.IGanjoorService.GetCategoryPaperSourcesAsync(System.Int32)">
<summary>
category paper sources
</summary>
<param name="categoryId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.IGanjoorService.MarkNaskbanLinksAsHumanReviewed(System.Int32,System.Int32,System.Boolean)">
<summary>
mark naskban links as human reviewed
@ -18189,6 +18217,13 @@
<param name="naskbanPassword"></param>
<returns>number of synched items</returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCategoryPaperSourcesAsync(System.Int32)">
<summary>
category paper sources
</summary>
<param name="categoryId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoetSuggestedSpecLinesAsync(System.Int32)">
<summary>
return list of suggested spec lines
@ -18750,13 +18785,14 @@
<param name="url"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCatByUrl(System.String,System.Boolean,System.Boolean)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCatByUrl(System.String,System.Boolean,System.Boolean,System.Boolean)">
<summary>
get cat by url
</summary>
<param name="url"></param>
<param name="poems"></param>
<param name="mainSections"></param>
<param name="paperSources"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetBooksAsync">
@ -18771,13 +18807,14 @@
</summary>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCatById(System.Int32,System.Boolean,System.Boolean)">
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetCatById(System.Int32,System.Boolean,System.Boolean,System.Boolean)">
<summary>
get cat by id
</summary>
<param name="id"></param>
<param name="poems"></param>
<param name="mainSections"></param>
<param name="paperSources"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPageUrlById(System.Int32)">

View File

@ -2,6 +2,7 @@
using RMuseum.Models.Ganjoor;
using RMuseum.Models.Ganjoor.ViewModels;
using RMuseum.Models.GanjoorAudio.ViewModels;
using RMuseum.Models.GanjoorIntegration;
using RSecurityBackend.Models.Generic;
using System;
using System.Threading.Tasks;
@ -50,8 +51,9 @@ namespace RMuseum.Services
/// <param name="id"></param>
/// <param name="poems"></param>
/// <param name="mainSections"></param>
/// <param name="paperSources"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = false, bool mainSections = false);
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = false, bool mainSections = false, bool paperSources = false);
/// <summary>
/// get cat by url
@ -59,8 +61,9 @@ namespace RMuseum.Services
/// <param name="url"></param>
/// <param name="poems"></param>
/// <param name="mainSections"></param>
/// <param name="paperSources"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = false, bool mainSections = false);
Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = false, bool mainSections = false, bool paperSources = false);
/// <summary>
/// Update category extra info
@ -1227,6 +1230,13 @@ namespace RMuseum.Services
/// <param name="naskbanPassword"></param>
void ImportNaskbanGanjoorPoemMatchFindings(string naskbanUserName, string naskbanPassword);
/// <summary>
/// category paper sources
/// </summary>
/// <param name="categoryId"></param>
/// <returns></returns>
Task<RServiceResult<GanjoorPaperSource[]>> GetCategoryPaperSourcesAsync(int categoryId);
/// <summary>
/// mark naskban links as human reviewed
/// </summary>

View File

@ -579,7 +579,7 @@ namespace RMuseum.Services.Implementation
var matchings = JsonConvert.DeserializeObject<GanjoorPoemMatchFinding[]>(await unsyncedResponse.Content.ReadAsStringAsync());
foreach (var matching in matchings)
{
if (false == await context.PaperSources.Where(p => p.NaskbanBookId == matching.BookId).AnyAsync())
if (false == await context.GanjoorPaperSources.Where(p => p.NaskbanBookId == matching.BookId).AnyAsync())
{
HttpResponseMessage responseBook = await secureClient.GetAsync($"https://api.naskban.ir/api/pdf/{matching.BookId}?includePages=false&includeBookText=false&includePageText=false");
if (responseBook.StatusCode != HttpStatusCode.OK)
@ -590,7 +590,7 @@ namespace RMuseum.Services.Implementation
var book = JsonConvert.DeserializeObject<PDFBook>(await responseBook.Content.ReadAsStringAsync());
var cat = await context.GanjoorCategories.AsNoTracking().Where(c => c.Id == matching.GanjoorCatId).SingleAsync();
PaperSource paperSource = new PaperSource()
GanjoorPaperSource paperSource = new GanjoorPaperSource()
{
GanjoorPoetId = cat.PoetId,
GanjoorCatId = matching.GanjoorCatId,
@ -607,7 +607,7 @@ namespace RMuseum.Services.Implementation
HumanReviewed = false,
OrderIndicator = 0,
};
context.PaperSources.Add(paperSource);
context.GanjoorPaperSources.Add(paperSource);
await context.SaveChangesAsync();
}
}
@ -622,5 +622,25 @@ namespace RMuseum.Services.Implementation
return new RServiceResult<int>(0, exp.ToString());
}
}
/// <summary>
/// category paper sources
/// </summary>
/// <param name="categoryId"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPaperSource[]>> GetCategoryPaperSourcesAsync(int categoryId)
{
try
{
return new RServiceResult<GanjoorPaperSource[]>
(
await _context.GanjoorPaperSources.AsNoTracking().Where(p => p.GanjoorCatId == categoryId).OrderBy(c => c.OrderIndicator).ThenBy(c => c.Id).ToArrayAsync()
);
}
catch (Exception exp)
{
return new RServiceResult<GanjoorPaperSource[]>(null, exp.ToString());
}
}
}
}

View File

@ -167,8 +167,9 @@ namespace RMuseum.Services.Implementation
/// <param name="url"></param>
/// <param name="poems"></param>
/// <param name="mainSections"></param>
/// <param name="paperSources"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = false, bool mainSections = false)
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatByUrl(string url, bool poems = false, bool mainSections = false, bool paperSources = false)
{
// /hafez/ => /hafez :
if (url.LastIndexOf('/') == url.Length - 1)
@ -178,7 +179,7 @@ namespace RMuseum.Services.Implementation
var cat = await _context.GanjoorCategories.Where(c => c.FullUrl == url).AsNoTracking().SingleOrDefaultAsync();
if (cat == null)
return new RServiceResult<GanjoorPoetCompleteViewModel>(null);
return await GetCatById(cat.Id, poems, mainSections);
return await GetCatById(cat.Id, poems, mainSections, paperSources);
}
@ -269,13 +270,14 @@ namespace RMuseum.Services.Implementation
/// <param name="id"></param>
/// <param name="poems"></param>
/// <param name="mainSections"></param>
/// <param name="paperSources"></param>
/// <returns></returns>
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = false, bool mainSections = false)
public async Task<RServiceResult<GanjoorPoetCompleteViewModel>> GetCatById(int id, bool poems = false, bool mainSections = false, bool paperSources = false)
{
return await _GetCatById(_context, id, poems, mainSections);
return await _GetCatById(_context, id, poems, mainSections, paperSources);
}
private async Task<RServiceResult<GanjoorPoetCompleteViewModel>> _GetCatById(RMuseumDbContext context, int id, bool poems = false, bool mainSections = false)
private async Task<RServiceResult<GanjoorPoetCompleteViewModel>> _GetCatById(RMuseumDbContext context, int id, bool poems = false, bool mainSections = false, bool paperSources = false)
{
var cat = await context.GanjoorCategories.Include(c => c.Poet).Include(c => c.Parent).Where(c => c.Id == id).AsNoTracking().FirstOrDefaultAsync();
if (cat == null)
@ -413,7 +415,8 @@ namespace RMuseum.Services.Implementation
}
).AsNoTracking().ToListAsync()
:
null
null,
PaperSources = paperSources ? await context.GanjoorPaperSources.AsNoTracking().Where(p => p.GanjoorCatId == cat.Id).ToListAsync() : null,
};
if (poems && mainSections)