docs: API for regenerating poem sections
This commit is contained in:
parent
7503d870f7
commit
a6911fb11c
@ -2813,6 +2813,24 @@ namespace RMuseum.Controllers
|
||||
return Ok(res.Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// regenerate poem sections (dangerous: wipes out existing data)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("poem/{id}/sections/regenerate")]
|
||||
[Authorize(Policy = RMuseumSecurableItem.GanjoorEntityShortName + ":" + SecurableItem.ModifyOperationShortName)]
|
||||
[ProducesResponseType((int)HttpStatusCode.OK)]
|
||||
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
|
||||
public async Task<IActionResult> RegeneratePoemSections(int id)
|
||||
{
|
||||
var res = await _ganjoorService.RegeneratePoemSections(id);
|
||||
if (!string.IsNullOrEmpty(res.ExceptionString))
|
||||
return BadRequest(res.ExceptionString);
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// update related sections manually
|
||||
|
||||
@ -1713,6 +1713,13 @@
|
||||
<param name="poemId"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.RegeneratePoemSections(System.Int32)">
|
||||
<summary>
|
||||
regenerate poem sections (dangerous: wipes out existing data)
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Controllers.GanjoorController.UpdateRelatedSections(System.Int32,System.String)">
|
||||
<summary>
|
||||
update related sections manually
|
||||
@ -12649,6 +12656,13 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.RegeneratePoemSections(System.Int32)">
|
||||
<summary>
|
||||
regenerate poem sections (dangerous: wipes out existing data)
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.IGanjoorService.GetPoemSectionByIdAsync(System.Int32)">
|
||||
<summary>
|
||||
get a specific poem section
|
||||
@ -14452,6 +14466,13 @@
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.RegeneratePoemSections(System.Int32)">
|
||||
<summary>
|
||||
regenerate poem sections (dangerous: wipes out existing data)
|
||||
</summary>
|
||||
<param name="id"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:RMuseum.Services.Implementation.GanjoorService.GetPoemSectionByIdAsync(System.Int32)">
|
||||
<summary>
|
||||
get a specific poem sections
|
||||
|
||||
@ -955,6 +955,13 @@ namespace RMuseum.Services
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<GanjoorPoemSection[]>> GetPoemSectionsAsync(int id);
|
||||
|
||||
/// <summary>
|
||||
/// regenerate poem sections (dangerous: wipes out existing data)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
Task<RServiceResult<bool>> RegeneratePoemSections(int id);
|
||||
|
||||
/// <summary>
|
||||
/// get a specific poem section
|
||||
/// </summary>
|
||||
|
||||
@ -642,6 +642,33 @@ namespace RMuseum.Services.Implementation
|
||||
return new RServiceResult<GanjoorPoemSection[]>(sections);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// regenerate poem sections (dangerous: wipes out existing data)
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<RServiceResult<bool>> RegeneratePoemSections(int id)
|
||||
{
|
||||
LongRunningJobProgressServiceEF jobProgressServiceEF = new LongRunningJobProgressServiceEF(_context);
|
||||
var job = (await jobProgressServiceEF.NewJob($"RegeneratePoemSections - {id}", "Query data")).Result;
|
||||
try
|
||||
{
|
||||
var sections = await _context.GanjoorPoemSections.Where(s => s.PoemId == id).ToListAsync();
|
||||
_context.RemoveRange(sections);
|
||||
await _context.SaveChangesAsync();
|
||||
var poem = await _context.GanjoorPoems.AsNoTracking().SingleAsync(p => p.Id == id);
|
||||
|
||||
await _SectionizePoem(_context, poem, jobProgressServiceEF, job);
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", true);
|
||||
return new RServiceResult<bool>(true);
|
||||
}
|
||||
catch (Exception exp)
|
||||
{
|
||||
await jobProgressServiceEF.UpdateJob(job.Id, 100, "", false, exp.ToString());
|
||||
return new RServiceResult<bool>(false, exp.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// get a specific poem sections
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user