mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
parent
b2195148a2
commit
4d2a311e40
@ -6,8 +6,7 @@ import SelectInput from './SelectInput';
|
|||||||
const availabilityOptions = [
|
const availabilityOptions = [
|
||||||
{ key: 'announced', value: translate('Announced') },
|
{ key: 'announced', value: translate('Announced') },
|
||||||
{ key: 'inCinemas', value: translate('InCinemas') },
|
{ key: 'inCinemas', value: translate('InCinemas') },
|
||||||
{ key: 'released', value: translate('Released') },
|
{ key: 'released', value: translate('Released') }
|
||||||
{ key: 'preDB', value: translate('PreDB') }
|
|
||||||
];
|
];
|
||||||
|
|
||||||
function AvailabilitySelectInput(props) {
|
function AvailabilitySelectInput(props) {
|
||||||
|
@ -0,0 +1,91 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using FluentAssertions;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using NzbDrone.Common.Serializer;
|
||||||
|
using NzbDrone.Core.Datastore.Migration;
|
||||||
|
using NzbDrone.Core.Test.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Test.Datastore.Migration
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class remove_predbFixture : MigrationTest<remove_predb>
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void should_change_min_avail_from_predb_on_list()
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c =>
|
||||||
|
{
|
||||||
|
c.Insert.IntoTable("ImportLists").Row(new
|
||||||
|
{
|
||||||
|
Enabled = 1,
|
||||||
|
EnableAuto = 1,
|
||||||
|
RootFolderPath = "D:\\Movies",
|
||||||
|
ProfileId = 1,
|
||||||
|
MinimumAvailability = 4,
|
||||||
|
ShouldMonitor = 1,
|
||||||
|
Name = "IMDB List",
|
||||||
|
Implementation = "RadarrLists",
|
||||||
|
Settings = new RadarrListSettings169
|
||||||
|
{
|
||||||
|
APIURL = "https://api.radarr.video/v2",
|
||||||
|
Path = "/imdb/list?listId=ls000199717",
|
||||||
|
}.ToJson(),
|
||||||
|
ConfigContract = "RadarrSettings"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var items = db.Query<ListDefinition201>("SELECT Id, MinimumAvailability FROM ImportLists");
|
||||||
|
|
||||||
|
items.Should().HaveCount(1);
|
||||||
|
items.First().MinimumAvailability.Should().Be(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void should_change_min_avail_from_predb_on_movie()
|
||||||
|
{
|
||||||
|
var db = WithMigrationTestDb(c =>
|
||||||
|
{
|
||||||
|
c.Insert.IntoTable("Movies").Row(new
|
||||||
|
{
|
||||||
|
Monitored = true,
|
||||||
|
Title = "Title",
|
||||||
|
CleanTitle = "CleanTitle",
|
||||||
|
Status = 3,
|
||||||
|
MinimumAvailability = 4,
|
||||||
|
Images = new[] { new { CoverType = "Poster" } }.ToJson(),
|
||||||
|
Recommendations = new[] { 1 }.ToJson(),
|
||||||
|
HasPreDBEntry = false,
|
||||||
|
Runtime = 90,
|
||||||
|
OriginalLanguage = 1,
|
||||||
|
ProfileId = 1,
|
||||||
|
MovieFileId = 0,
|
||||||
|
Path = string.Format("/Movies/{0}", "Title"),
|
||||||
|
TitleSlug = 123456,
|
||||||
|
TmdbId = 132456,
|
||||||
|
Added = DateTime.UtcNow,
|
||||||
|
LastInfoSync = DateTime.UtcNow,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
var items = db.Query<Movie201>("SELECT Id, MinimumAvailability FROM Movies");
|
||||||
|
|
||||||
|
items.Should().HaveCount(1);
|
||||||
|
items.First().MinimumAvailability.Should().Be(3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ListDefinition201
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int MinimumAvailability { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Movie201
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int MinimumAvailability { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using FluentMigrator;
|
using FluentMigrator;
|
||||||
|
|
||||||
//using FluentMigrator.Expressions;
|
//using FluentMigrator.Expressions;
|
||||||
using NzbDrone.Core.Datastore.Migration.Framework;
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
@ -13,12 +13,12 @@ protected override void MainDbUpgrade()
|
|||||||
{
|
{
|
||||||
if (!Schema.Schema("dbo").Table("NetImport").Column("MinimumAvailability").Exists())
|
if (!Schema.Schema("dbo").Table("NetImport").Column("MinimumAvailability").Exists())
|
||||||
{
|
{
|
||||||
Alter.Table("NetImport").AddColumn("MinimumAvailability").AsInt32().WithDefaultValue(MovieStatusType.PreDB);
|
Alter.Table("NetImport").AddColumn("MinimumAvailability").AsInt32().WithDefaultValue(MovieStatusType.Released);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Schema.Schema("dbo").Table("Movies").Column("MinimumAvailability").Exists())
|
if (!Schema.Schema("dbo").Table("Movies").Column("MinimumAvailability").Exists())
|
||||||
{
|
{
|
||||||
Alter.Table("Movies").AddColumn("MinimumAvailability").AsInt32().WithDefaultValue(MovieStatusType.PreDB);
|
Alter.Table("Movies").AddColumn("MinimumAvailability").AsInt32().WithDefaultValue(MovieStatusType.Released);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
src/NzbDrone.Core/Datastore/Migration/202_remove_predb.cs
Normal file
23
src/NzbDrone.Core/Datastore/Migration/202_remove_predb.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using FluentMigrator;
|
||||||
|
using NzbDrone.Core.Datastore.Migration.Framework;
|
||||||
|
|
||||||
|
namespace NzbDrone.Core.Datastore.Migration
|
||||||
|
{
|
||||||
|
[Migration(202)]
|
||||||
|
public class remove_predb : NzbDroneMigrationBase
|
||||||
|
{
|
||||||
|
protected override void MainDbUpgrade()
|
||||||
|
{
|
||||||
|
//Set PreDb entries to Released
|
||||||
|
Update.Table("Movies").Set(new { MinimumAvailability = 3 }).Where(new { MinimumAvailability = 4 });
|
||||||
|
Update.Table("ImportLists").Set(new { MinimumAvailability = 3 }).Where(new { MinimumAvailability = 4 });
|
||||||
|
|
||||||
|
//Should never be set, but just in case
|
||||||
|
Update.Table("Movies").Set(new { Status = 3 }).Where(new { Status = 4 });
|
||||||
|
Update.Table("ImportListMovies").Set(new { Status = 3 }).Where(new { Status = 4 });
|
||||||
|
|
||||||
|
//Remove unused column
|
||||||
|
Delete.Column("HasPreDBEntry").FromTable("Movies");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -56,7 +56,6 @@ public Movie()
|
|||||||
public HashSet<int> Tags { get; set; }
|
public HashSet<int> Tags { get; set; }
|
||||||
public AddMovieOptions AddOptions { get; set; }
|
public AddMovieOptions AddOptions { get; set; }
|
||||||
public MovieFile MovieFile { get; set; }
|
public MovieFile MovieFile { get; set; }
|
||||||
public bool HasPreDBEntry { get; set; }
|
|
||||||
public int MovieFileId { get; set; }
|
public int MovieFileId { get; set; }
|
||||||
|
|
||||||
//Get Loaded via a Join Query
|
//Get Loaded via a Join Query
|
||||||
@ -137,11 +136,6 @@ public bool IsAvailable(int delay = 0)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HasPreDBEntry && MinimumAvailability == MovieStatusType.PreDB)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minimumAvailabilityDate == DateTime.MinValue || minimumAvailabilityDate == DateTime.MaxValue)
|
if (minimumAvailabilityDate == DateTime.MinValue || minimumAvailabilityDate == DateTime.MaxValue)
|
||||||
{
|
{
|
||||||
return DateTime.Now >= minimumAvailabilityDate;
|
return DateTime.Now >= minimumAvailabilityDate;
|
||||||
|
@ -7,6 +7,5 @@ public enum MovieStatusType
|
|||||||
Announced = 1, //Movie is announced but Cinema date is in the future or unknown
|
Announced = 1, //Movie is announced but Cinema date is in the future or unknown
|
||||||
InCinemas = 2, //Been in Cinemas for less than 3 months (since TMDB lacks complete information)
|
InCinemas = 2, //Been in Cinemas for less than 3 months (since TMDB lacks complete information)
|
||||||
Released = 3, //Physical or Web Release or been in cinemas for > 3 months (since TMDB lacks complete information)
|
Released = 3, //Physical or Web Release or been in cinemas for > 3 months (since TMDB lacks complete information)
|
||||||
PreDB = 4 //this is only used for MinimumAvailability. Movie items should never be in this state.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +117,6 @@ private Movie RefreshMovieInfo(int movieId)
|
|||||||
movie.Studio = movieInfo.Studio;
|
movie.Studio = movieInfo.Studio;
|
||||||
movie.OriginalTitle = movieInfo.OriginalTitle;
|
movie.OriginalTitle = movieInfo.OriginalTitle;
|
||||||
movie.OriginalLanguage = movieInfo.OriginalLanguage;
|
movie.OriginalLanguage = movieInfo.OriginalLanguage;
|
||||||
movie.HasPreDBEntry = movieInfo.HasPreDBEntry;
|
|
||||||
movie.Recommendations = movieInfo.Recommendations;
|
movie.Recommendations = movieInfo.Recommendations;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
Loading…
Reference in New Issue
Block a user