From d33788f5d4cc586bc94174971e3f49db72425284 Mon Sep 17 00:00:00 2001 From: Lawrence Angrave Date: Thu, 25 Jan 2024 23:02:31 -0600 Subject: [PATCH 1/2] Log extra details --- TaskEngine/Tasks/DownloadPlaylistInfoTask.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/TaskEngine/Tasks/DownloadPlaylistInfoTask.cs b/TaskEngine/Tasks/DownloadPlaylistInfoTask.cs index 8321de5..932b3f3 100644 --- a/TaskEngine/Tasks/DownloadPlaylistInfoTask.cs +++ b/TaskEngine/Tasks/DownloadPlaylistInfoTask.cs @@ -47,7 +47,19 @@ protected override async Task OnConsume(string playlistId, TaskParameters taskPa RegisterTask(cleanup, playlistId); // may throw AlreadyInProgress exception using (var _context = CTDbContext.CreateDbContext()) { - var playlist = await _context.Playlists.FindAsync(playlistId); + + var playlist = await _context.Playlists.Include(p=>p.Offering).Where(p=> p.Id == playlistId).FirstOrDefaultAsync(); + if (playlist == null) + { + GetLogger().LogError($"Playlist {playlistId} not found"); + return; + } + if(playlist.Offering == null || playlist.Offering.CourseName == null) + { + GetLogger().LogError($"Playlist {playlistId} has no associated offering "); + return; + } + GetLogger().LogInformation($"Playlist {playlistId}:<{playlist.Name}>/{playlist.Offering.CourseName}: type=({playlist.SourceType}) unique=({playlist.PlaylistIdentifier})"); int index = 0; try { index = 1 + await _context.Medias.Where(m=> m.PlaylistId == playlist.Id).Select(m => m.Index).MaxAsync(); @@ -82,6 +94,7 @@ protected override async Task OnConsume(string playlistId, TaskParameters taskPa playlist.ListUpdatedAt = playlist.ListCheckedAt; } await _context.SaveChangesAsync(); + GetLogger().LogInformation($"Playlist {playlistId}: Task Complete"); } } From d68e773d5e68ed59c536c19841fef2be383982b3 Mon Sep 17 00:00:00 2001 From: Lawrence Angrave Date: Thu, 25 Jan 2024 23:03:14 -0600 Subject: [PATCH 2/2] Created in last 3 montgs --- TaskEngine/Tasks/QueueAwakerTask.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/TaskEngine/Tasks/QueueAwakerTask.cs b/TaskEngine/Tasks/QueueAwakerTask.cs index a6167f9..34e993d 100644 --- a/TaskEngine/Tasks/QueueAwakerTask.cs +++ b/TaskEngine/Tasks/QueueAwakerTask.cs @@ -198,18 +198,19 @@ private async Task PendingJobs() // todoVTTs = await context.Transcriptions.AsNoTracking().Where( // t => t.Captions.Count > 0 && t.File == null && t.CreatedAt < tooRecentCutoff // ).OrderByDescending(t => t.CreatedAt).Take(maxVTTs).Select(e => e.Id).ToListAsync(); + var last3Months = DateTime.Now.AddMonths(-3); var maxSceneDetection = 400; todoSceneDetection = await context.Videos.AsNoTracking().Where( v=> (v.PhraseHintsDataId== null) && v.PhraseHints == null && - v.Medias.Any() && v.CreatedAt < tooRecentCutoff + v.Medias.Any() && v.CreatedAt < tooRecentCutoff && v.CreatedAt > last3Months ).OrderByDescending(t => t.CreatedAt).Take(maxSceneDetection).Select(e => e.Id).ToListAsync(); var maxTranscriptions = 40; todoTranscriptions = await context.Videos.AsNoTracking().Where( v=> (v.PhraseHintsDataId != null || v.PhraseHints != null) && v.TranscribingAttempts < 41 && v.TranscriptionStatus != "NoError" && - v.Medias.Any() && v.CreatedAt < tooRecentCutoff + v.Medias.Any() && v.CreatedAt < tooRecentCutoff && v.CreatedAt > last3Months ).OrderByDescending(t => t.CreatedAt).Take(maxTranscriptions).Select(e => e.Id).ToListAsync(); // Medias for which no videos have downloaded