Added refreshed since for channels

This commit is contained in:
2018-02-20 01:16:30 -05:00
parent 66a9c1edb4
commit e11ddfa72c
6 changed files with 156 additions and 9 deletions

View File

@ -58,7 +58,8 @@ namespace YTManager.Tasks {
Title = response.Items.First().Snippet.Title,
ThumbnailURL = response.Items.First().Snippet.Thumbnails.Medium.Url,
YoutubeID = channelID,
AddedtoDB = DateTime.Now
AddedtoDB = DateTime.Now,
Refreshed = DateTime.MinValue
};
}
@ -68,10 +69,12 @@ namespace YTManager.Tasks {
var ops = new DbContextOptionsBuilder<MediaDB>();
ops.UseNpgsql(dbstr);
// Get all the channels from the db.
// Get all the channels from the db that expired.
var threshold = DateTime.Now.Subtract(TimeSpan.FromSeconds(100));
var channel_ids = await
(new MediaDB(ops.Options))
.Channels.Select(ch => ch.YoutubeID)
(new MediaDB(ops.Options)).Channels
.Where(ch => ch.Refreshed < threshold)
.Select(ch => ch.YoutubeID)
.ToListAsync();
// For each channel, do an update.