mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
Fixed #2801 this is when a season is not correctly monitored in sonarr when approved by an admin
This commit is contained in:
parent
d834b96b4b
commit
ada38a0c30
7 changed files with 1309 additions and 63 deletions
|
@ -385,6 +385,7 @@ namespace Ombi.Core.Engine
|
||||||
foreach (var ep in s.Episodes)
|
foreach (var ep in s.Episodes)
|
||||||
{
|
{
|
||||||
ep.Approved = true;
|
ep.Approved = true;
|
||||||
|
ep.Requested = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ using Ombi.Settings.Settings.Models.External;
|
||||||
using Ombi.Store.Entities;
|
using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Entities.Requests;
|
using Ombi.Store.Entities.Requests;
|
||||||
using Ombi.Store.Repository;
|
using Ombi.Store.Repository;
|
||||||
|
using Remotion.Linq.Parsing.Structure.IntermediateModel;
|
||||||
|
|
||||||
namespace Ombi.Core.Senders
|
namespace Ombi.Core.Senders
|
||||||
{
|
{
|
||||||
|
@ -314,10 +315,19 @@ namespace Ombi.Core.Senders
|
||||||
|
|
||||||
foreach (var season in model.SeasonRequests)
|
foreach (var season in model.SeasonRequests)
|
||||||
{
|
{
|
||||||
var sonarrSeason = sonarrEpList.Where(x => x.seasonNumber == season.SeasonNumber);
|
var sonarrEpisodeList = sonarrEpList.Where(x => x.seasonNumber == season.SeasonNumber).ToList();
|
||||||
var sonarrEpCount = sonarrSeason.Count();
|
var sonarrEpCount = sonarrEpisodeList.Count;
|
||||||
var ourRequestCount = season.Episodes.Count;
|
var ourRequestCount = season.Episodes.Count;
|
||||||
|
|
||||||
|
var ourEpisodes = season.Episodes.Select(x => x.EpisodeNumber).ToList();
|
||||||
|
var unairedEpisodes = sonarrEpisodeList.Where(x => x.airDateUtc > DateTime.UtcNow).Select(x => x.episodeNumber).ToList();
|
||||||
|
|
||||||
|
//// Check if we have requested all the latest episodes, if we have then monitor
|
||||||
|
//// NOTE, not sure if needed since ombi ui displays future episodes anyway...
|
||||||
|
//ourEpisodes.AddRange(unairedEpisodes);
|
||||||
|
//var distinctEpisodes = ourEpisodes.Distinct().ToList();
|
||||||
|
//var missingEpisodes = Enumerable.Range(distinctEpisodes.Min(), distinctEpisodes.Count).Except(distinctEpisodes);
|
||||||
|
|
||||||
var existingSeason =
|
var existingSeason =
|
||||||
result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
|
result.seasons.FirstOrDefault(x => x.seasonNumber == season.SeasonNumber);
|
||||||
if (existingSeason == null)
|
if (existingSeason == null)
|
||||||
|
@ -327,7 +337,7 @@ namespace Ombi.Core.Senders
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (sonarrEpCount == ourRequestCount)
|
if (sonarrEpCount == ourRequestCount /*|| !missingEpisodes.Any()*/)
|
||||||
{
|
{
|
||||||
// We have the same amount of requests as all of the episodes in the season.
|
// We have the same amount of requests as all of the episodes in the season.
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,6 @@ namespace Ombi.Store.Entities.Requests
|
||||||
public DateTime ReleaseDate { get; set; }
|
public DateTime ReleaseDate { get; set; }
|
||||||
public string Status { get; set; }
|
public string Status { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This is so we can correctly send the right amount of seasons to Sonarr
|
|
||||||
/// </summary>
|
|
||||||
[NotMapped]
|
|
||||||
public int TotalSeasons { get; set; }
|
public int TotalSeasons { get; set; }
|
||||||
|
|
||||||
public List<ChildRequests> ChildRequests { get; set; }
|
public List<ChildRequests> ChildRequests { get; set; }
|
||||||
|
|
1214
src/Ombi.Store/Migrations/20190216231519_TvRequestsTotalSeasons.Designer.cs
generated
Normal file
1214
src/Ombi.Store/Migrations/20190216231519_TvRequestsTotalSeasons.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,23 @@
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace Ombi.Store.Migrations
|
||||||
|
{
|
||||||
|
public partial class TvRequestsTotalSeasons : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "TotalSeasons",
|
||||||
|
table: "TvRequests",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TotalSeasons",
|
||||||
|
table: "TvRequests");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -819,6 +819,8 @@ namespace Ombi.Store.Migrations
|
||||||
|
|
||||||
b.Property<string>("Title");
|
b.Property<string>("Title");
|
||||||
|
|
||||||
|
b.Property<int>("TotalSeasons");
|
||||||
|
|
||||||
b.Property<int>("TvDbId");
|
b.Property<int>("TvDbId");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
|
@ -1,60 +1,60 @@
|
||||||
using System.Net.Http;
|
//using System.Net.Http;
|
||||||
using System.Threading.Tasks;
|
//using System.Threading.Tasks;
|
||||||
using AutoMapper;
|
//using AutoMapper;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
//using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.AspNetCore.Http;
|
//using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Http.Features.Authentication;
|
//using Microsoft.AspNetCore.Http.Features.Authentication;
|
||||||
using Microsoft.AspNetCore.Identity;
|
//using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
//using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Options;
|
//using Microsoft.Extensions.Options;
|
||||||
using Moq;
|
//using Moq;
|
||||||
using NUnit.Framework;
|
//using NUnit.Framework;
|
||||||
using Ombi.Api.Emby;
|
//using Ombi.Api.Emby;
|
||||||
using Ombi.Api.Plex;
|
//using Ombi.Api.Plex;
|
||||||
using Ombi.Controllers;
|
//using Ombi.Controllers;
|
||||||
using Ombi.Core.Authentication;
|
//using Ombi.Core.Authentication;
|
||||||
using Ombi.Core.Settings;
|
//using Ombi.Core.Settings;
|
||||||
using Ombi.Core.Settings.Models.External;
|
//using Ombi.Core.Settings.Models.External;
|
||||||
using Ombi.Models.Identity;
|
//using Ombi.Models.Identity;
|
||||||
using Ombi.Notifications;
|
//using Ombi.Notifications;
|
||||||
using Ombi.Schedule.Jobs.Ombi;
|
//using Ombi.Schedule.Jobs.Ombi;
|
||||||
using Ombi.Settings.Settings.Models;
|
//using Ombi.Settings.Settings.Models;
|
||||||
using Ombi.Settings.Settings.Models.Notifications;
|
//using Ombi.Settings.Settings.Models.Notifications;
|
||||||
using Ombi.Store.Context;
|
//using Ombi.Store.Context;
|
||||||
using Ombi.Store.Entities;
|
//using Ombi.Store.Entities;
|
||||||
using Ombi.Store.Repository;
|
//using Ombi.Store.Repository;
|
||||||
using Microsoft.AspNetCore.Hosting.Server;
|
//using Microsoft.AspNetCore.Hosting.Server;
|
||||||
using Microsoft.AspNetCore.TestHost;
|
//using Microsoft.AspNetCore.TestHost;
|
||||||
using Newtonsoft.Json;
|
//using Newtonsoft.Json;
|
||||||
using Ombi.Models;
|
//using Ombi.Models;
|
||||||
|
|
||||||
namespace Ombi.Tests
|
//namespace Ombi.Tests
|
||||||
{
|
//{
|
||||||
[TestFixture]
|
// [TestFixture]
|
||||||
[Ignore("TODO")]
|
// [Ignore("TODO")]
|
||||||
public class TokenControllerTests
|
// public class TokenControllerTests
|
||||||
{
|
// {
|
||||||
[SetUp]
|
// [SetUp]
|
||||||
public void Setup()
|
// public void Setup()
|
||||||
{
|
// {
|
||||||
_testServer = new TestServer(new WebHostBuilder()
|
// _testServer = new TestServer(new WebHostBuilder()
|
||||||
.UseStartup<TestStartup>());
|
// .UseStartup<TestStartup>());
|
||||||
_client = _testServer.CreateClient();
|
// _client = _testServer.CreateClient();
|
||||||
}
|
// }
|
||||||
|
|
||||||
private TestServer _testServer;
|
// private TestServer _testServer;
|
||||||
private HttpClient _client;
|
// private HttpClient _client;
|
||||||
|
|
||||||
|
|
||||||
[Test]
|
// [Test]
|
||||||
public async Task GetToken_FromValid_LocalUser()
|
// public async Task GetToken_FromValid_LocalUser()
|
||||||
{
|
// {
|
||||||
var model = new UserAuthModel
|
// var model = new UserAuthModel
|
||||||
{
|
// {
|
||||||
Password = "a",
|
// Password = "a",
|
||||||
Username = "a"
|
// Username = "a"
|
||||||
};
|
// };
|
||||||
HttpResponseMessage response = await _client.PostAsync("/api/v1/token", new StringContent(JsonConvert.SerializeObject(model)) );
|
// HttpResponseMessage response = await _client.PostAsync("/api/v1/token", new StringContent(JsonConvert.SerializeObject(model)) );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
Loading…
Add table
Add a link
Reference in a new issue