* refactor create playout handler * refactor get all playouts handler * refactor delete playout handler * remove dead code * ignore unnamed artists for collections * more repository cleanup * more schedule items refactoring * more playout refactoring * refactor playout builder * refactor ffmpeg profiles * more ffmpeg profile refactoring * rework resolutions * refactor media collections * refactor config elements * update changelog * more cleanup
24 lines
749 B
C#
24 lines
749 B
C#
using System;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using ErsatzTV.Core.Domain;
|
|
using LanguageExt;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using static LanguageExt.Prelude;
|
|
|
|
namespace ErsatzTV.Infrastructure.Extensions
|
|
{
|
|
public static class PlayoutItemQueryableExtensions
|
|
{
|
|
public static Task<Option<PlayoutItem>> ForChannelAndTime(
|
|
this IQueryable<PlayoutItem> dbSet,
|
|
int channelId,
|
|
DateTimeOffset time) =>
|
|
dbSet.Filter(pi => pi.Playout.ChannelId == channelId)
|
|
.Filter(pi => pi.Start <= time.UtcDateTime && pi.Finish > time.UtcDateTime)
|
|
.OrderBy(pi => pi.Start)
|
|
.FirstOrDefaultAsync()
|
|
.Map(Optional);
|
|
}
|
|
}
|