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"); } } 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