#455 improvements

This commit is contained in:
Hamid Reza Mohammadi 2024-12-14 17:03:13 +03:30
parent 236b4a5db9
commit 60286749ae
3 changed files with 8 additions and 8 deletions

View File

@ -2112,7 +2112,7 @@ namespace RMuseum.Controllers
/// <summary>
/// create images for ganjoor
/// </summary>
/// <param name="poetId"></param>
/// <param name="startPoetId"></param>
/// <returns></returns>
[HttpPut("ai/create/images")]
@ -2120,11 +2120,11 @@ namespace RMuseum.Controllers
[ProducesResponseType((int)HttpStatusCode.OK)]
[ProducesResponseType((int)HttpStatusCode.BadRequest, Type = typeof(string))]
[ProducesResponseType((int)HttpStatusCode.Unauthorized)]
public async Task<IActionResult> OpenAIStartCreatingImagesForPoemsAsync(int poetId = 0)
public async Task<IActionResult> OpenAIStartCreatingImagesForPoemsAsync(int startPoetId = 0)
{
try
{
await _artifactService.OpenAIStartCreatingImagesForPoemsAsync(poetId);
await _artifactService.OpenAIStartCreatingImagesForPoemsAsync(startPoetId);
return Ok();
}
catch (Exception exp)

View File

@ -602,9 +602,9 @@ namespace RMuseum.Services
/// <summary>
/// create images for ganjoor
/// </summary>
/// <param name="poetId"></param>
/// <param name="startPoetId"></param>
/// <returns></returns>
Task OpenAIStartCreatingImagesForPoemsAsync(int poetId);
Task OpenAIStartCreatingImagesForPoemsAsync(int startPoetId);
}
}

View File

@ -24,7 +24,7 @@ namespace RMuseum.Services.Implementation
/// </summary>
public partial class ArtifactService : IArtifactService
{
public async Task OpenAIStartCreatingImagesForPoemsAsync(int poetId)
public async Task OpenAIStartCreatingImagesForPoemsAsync(int startPoetId)
{
string systemEmail = $"{Configuration.GetSection("Ganjoor")["SystemEmail"]}";
var systemUserId = (Guid)(await _userService.FindUserByEmail(systemEmail)).Result.Id;
@ -72,13 +72,13 @@ namespace RMuseum.Services.Implementation
}
await jobProgressServiceEF.UpdateJob(job.Id, 0, $"Query Poems");
var poets = await context.GanjoorPoets.AsNoTracking().Where(p => poetId == 0 || p.Id == poetId).OrderBy(p => p.Id).ToListAsync();
var poets = await context.GanjoorPoets.AsNoTracking().Where(p => p.Id >= startPoetId).OrderBy(p => p.Id).ToListAsync();
foreach (var poet in poets)
{
if (poet.Id < 5) continue;
var poems = await context.GanjoorPoems.Include(p => p.Cat).AsNoTracking().Where(p => p.Cat.PoetId == poet.Id).ToListAsync();
await jobProgressServiceEF.UpdateJob(job.Id, 0, $"PoetId = {poetId}, Starting, {poems.Count}");
await jobProgressServiceEF.UpdateJob(job.Id, 0, $"PoetId = {poet.Id}, Starting, {poems.Count}");
for (var i = 0; i < poems.Count; i++)
{
var poem = poems[i];