Browse Source

fix block history and smart_collection search bugs (#2579)

* fix block history when using mirror offset

* fix smart_collection search crashes
pull/2580/head
Jason Dove 9 months ago committed by GitHub
parent
commit
727a978689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      CHANGELOG.md
  2. 4
      ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs
  3. 2
      ErsatzTV.Core/Scheduling/BlockScheduling/BlockPlayoutBuilder.cs
  4. 9
      ErsatzTV.Core/Scheduling/ChronologicalMediaCollectionEnumerator.cs
  5. 9
      ErsatzTV.Infrastructure/Search/SearchQueryParser.cs
  6. 2
      ErsatzTV/Pages/Playouts.razor

3
CHANGELOG.md

@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). @@ -7,6 +7,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Fixed
- Fix HLS Direct playback with Jellyfin 10.11
- Fix remote stream scripts (parsing issue with spaces and quotes)
- Fix block history being removed when it is still needed for mirror channel
- This caused playout build errors like "Unable to locate history for playout item"
- Fix crashes due to invalid smart collection searches, e.g. `smart_collection:"this collection does not exist"`
## [25.8.0] - 2025-10-26
### Added

4
ErsatzTV.Application/Playouts/Commands/BuildPlayoutHandler.cs

@ -367,8 +367,8 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro @@ -367,8 +367,8 @@ public class BuildPlayoutHandler : IRequestHandler<BuildPlayout, Either<BaseErro
{
try
{
await dbContext.PlayoutBuildStatus.AddAsync(newBuildStatus, cancellationToken);
await dbContext.SaveChangesAsync(cancellationToken);
await dbContext.PlayoutBuildStatus.AddAsync(newBuildStatus, CancellationToken.None);
await dbContext.SaveChangesAsync(CancellationToken.None);
}
catch (Exception)
{

2
ErsatzTV.Core/Scheduling/BlockScheduling/BlockPlayoutBuilder.cs

@ -397,7 +397,7 @@ public class BlockPlayoutBuilder( @@ -397,7 +397,7 @@ public class BlockPlayoutBuilder(
IEnumerable<PlayoutHistory> allItemsToDelete = referenceData.PlayoutHistory
.GroupBy(h => h.Key)
.SelectMany(group => group
.Filter(h => h.Finish < start.UtcDateTime)
.Filter(h => h.Finish < start.UtcDateTime - referenceData.MaxPlayoutOffset)
.OrderByDescending(h => h.Finish)
.Tail());

9
ErsatzTV.Core/Scheduling/ChronologicalMediaCollectionEnumerator.cs

@ -45,8 +45,13 @@ public sealed class ChronologicalMediaCollectionEnumerator : IMediaCollectionEnu @@ -45,8 +45,13 @@ public sealed class ChronologicalMediaCollectionEnumerator : IMediaCollectionEnu
public Option<MediaItem> Current => _sortedMediaItems.Count != 0 ? _sortedMediaItems[State.Index] : None;
public Option<bool> CurrentIncludeInProgramGuide { get; }
public void MoveNext(Option<DateTimeOffset> scheduledAt) =>
State.Index = (State.Index + 1) % _sortedMediaItems.Count;
public void MoveNext(Option<DateTimeOffset> scheduledAt)
{
if (_sortedMediaItems.Count > 0)
{
State.Index = (State.Index + 1) % _sortedMediaItems.Count;
}
}
public Option<TimeSpan> MinimumDuration => _lazyMinimumDuration.Value;

9
ErsatzTV.Infrastructure/Search/SearchQueryParser.cs

@ -77,7 +77,8 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -77,7 +77,8 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
if (parsedQuery == replaceResult.Query)
{
logger.LogWarning(
"Failed to replace smart_collection in query; is the syntax correct? Quotes are required. Giving up...");
"Failed to replace smart_collection in query; is the syntax correct? Quotes are required. Giving up on collection {Name}...",
smartCollectionName);
break;
}
@ -125,6 +126,12 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach @@ -125,6 +126,12 @@ public partial class SearchQueryParser(ISmartCollectionCache smartCollectionCach
{
result = result.Replace(match.Value, $"({smartCollectionQuery})");
}
if (maybeQuery.IsNone)
{
//logger.LogError("Cannot find nested smart collection {Name}; removing from query.", smartCollectionName);
result = result.Replace(match.Value, "(type:bad_query)");
}
}
return new ReplaceResult(result, false);

2
ErsatzTV/Pages/Playouts.razor

@ -366,7 +366,7 @@ @@ -366,7 +366,7 @@
? playout.PlayoutId
: null;
_buildMessage = !playout.BuildStatus.Success && !string.IsNullOrWhiteSpace(playout.BuildStatus.Message)
_buildMessage = !(playout.BuildStatus?.Success ?? false) && !string.IsNullOrWhiteSpace(playout.BuildStatus?.Message)
? playout.BuildStatus.Message
: string.Empty;

Loading…
Cancel
Save