mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Remove old watched episode and comment out usless people implementation
This commit is contained in:
parent
070a94d87d
commit
8ea8d3ff57
@ -125,10 +125,10 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
[LoadableRelation(nameof(StudioId))] public Studio? Studio { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of people that made this show.
|
||||
/// </summary>
|
||||
[SerializeIgnore] public ICollection<PeopleRole>? People { get; set; }
|
||||
// /// <summary>
|
||||
// /// The list of people that made this show.
|
||||
// /// </summary>
|
||||
// [SerializeIgnore] public ICollection<PeopleRole>? People { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of collections that contains this show.
|
||||
@ -147,11 +147,11 @@ namespace Kyoo.Abstractions.Models
|
||||
/// <inheritdoc />
|
||||
public void OnMerge(object merged)
|
||||
{
|
||||
if (People != null)
|
||||
{
|
||||
foreach (PeopleRole link in People)
|
||||
link.Movie = this;
|
||||
}
|
||||
// if (People != null)
|
||||
// {
|
||||
// foreach (PeopleRole link in People)
|
||||
// link.Movie = this;
|
||||
// }
|
||||
}
|
||||
|
||||
public Movie() { }
|
||||
|
@ -128,10 +128,10 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
[LoadableRelation(nameof(StudioId))] public Studio? Studio { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of people that made this show.
|
||||
/// </summary>
|
||||
[SerializeIgnore] public ICollection<PeopleRole>? People { get; set; }
|
||||
// /// <summary>
|
||||
// /// The list of people that made this show.
|
||||
// /// </summary>
|
||||
// [SerializeIgnore] public ICollection<PeopleRole>? People { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The different seasons in this show. If this is a movie, this list is always null or empty.
|
||||
@ -181,11 +181,11 @@ namespace Kyoo.Abstractions.Models
|
||||
/// <inheritdoc />
|
||||
public void OnMerge(object merged)
|
||||
{
|
||||
if (People != null)
|
||||
{
|
||||
foreach (PeopleRole link in People)
|
||||
link.Show = this;
|
||||
}
|
||||
// if (People != null)
|
||||
// {
|
||||
// foreach (PeopleRole link in People)
|
||||
// link.Show = this;
|
||||
// }
|
||||
|
||||
if (Seasons != null)
|
||||
{
|
||||
|
@ -69,18 +69,6 @@ namespace Kyoo.Abstractions.Models
|
||||
/// </summary>
|
||||
public Image? Logo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of shows the user has finished.
|
||||
/// </summary>
|
||||
[SerializeIgnore]
|
||||
public ICollection<Show>? Watched { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of episodes the user is watching (stopped in progress or the next episode of the show)
|
||||
/// </summary>
|
||||
[SerializeIgnore]
|
||||
public ICollection<WatchedEpisode>? CurrentlyWatching { get; set; }
|
||||
|
||||
public User() { }
|
||||
|
||||
[JsonConstructor]
|
||||
|
@ -1,46 +0,0 @@
|
||||
// Kyoo - A portable and vast media library solution.
|
||||
// Copyright (c) Kyoo.
|
||||
//
|
||||
// See AUTHORS.md and LICENSE file in the project root for full license information.
|
||||
//
|
||||
// Kyoo is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// any later version.
|
||||
//
|
||||
// Kyoo is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Kyoo. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
namespace Kyoo.Abstractions.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// Metadata of episode currently watching by an user
|
||||
/// </summary>
|
||||
public class WatchedEpisode
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the user that started watching this episode.
|
||||
/// </summary>
|
||||
public int UserID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the episode started.
|
||||
/// </summary>
|
||||
public int EpisodeID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Episode"/> started.
|
||||
/// </summary>
|
||||
public Episode? Episode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Where the player has stopped watching the episode (between 0 and 100).
|
||||
/// </summary>
|
||||
public int WatchedPercentage { get; set; }
|
||||
}
|
||||
}
|
@ -94,16 +94,16 @@ namespace Kyoo.Core.Controllers
|
||||
resource.StudioId = resource.Studio.Id;
|
||||
}
|
||||
|
||||
if (resource.People != null)
|
||||
{
|
||||
foreach (PeopleRole role in resource.People)
|
||||
{
|
||||
role.People = _database.LocalEntity<People>(role.People.Slug)
|
||||
?? await _people.CreateIfNotExists(role.People);
|
||||
role.PeopleID = role.People.Id;
|
||||
_database.Entry(role).State = EntityState.Added;
|
||||
}
|
||||
}
|
||||
// if (resource.People != null)
|
||||
// {
|
||||
// foreach (PeopleRole role in resource.People)
|
||||
// {
|
||||
// role.People = _database.LocalEntity<People>(role.People.Slug)
|
||||
// ?? await _people.CreateIfNotExists(role.People);
|
||||
// role.PeopleID = role.People.Id;
|
||||
// _database.Entry(role).State = EntityState.Added;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -117,11 +117,11 @@ namespace Kyoo.Core.Controllers
|
||||
resource.Studio = changed.Studio;
|
||||
}
|
||||
|
||||
if (changed.People != null)
|
||||
{
|
||||
await Database.Entry(resource).Collection(x => x.People!).LoadAsync();
|
||||
resource.People = changed.People;
|
||||
}
|
||||
// if (changed.People != null)
|
||||
// {
|
||||
// await Database.Entry(resource).Collection(x => x.People!).LoadAsync();
|
||||
// resource.People = changed.People;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -95,16 +95,16 @@ namespace Kyoo.Core.Controllers
|
||||
resource.StudioId = resource.Studio.Id;
|
||||
}
|
||||
|
||||
if (resource.People != null)
|
||||
{
|
||||
foreach (PeopleRole role in resource.People)
|
||||
{
|
||||
role.People = _database.LocalEntity<People>(role.People.Slug)
|
||||
?? await _people.CreateIfNotExists(role.People);
|
||||
role.PeopleID = role.People.Id;
|
||||
_database.Entry(role).State = EntityState.Added;
|
||||
}
|
||||
}
|
||||
// if (resource.People != null)
|
||||
// {
|
||||
// foreach (PeopleRole role in resource.People)
|
||||
// {
|
||||
// role.People = _database.LocalEntity<People>(role.People.Slug)
|
||||
// ?? await _people.CreateIfNotExists(role.People);
|
||||
// role.PeopleID = role.People.Id;
|
||||
// _database.Entry(role).State = EntityState.Added;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -118,11 +118,11 @@ namespace Kyoo.Core.Controllers
|
||||
resource.Studio = changed.Studio;
|
||||
}
|
||||
|
||||
if (changed.People != null)
|
||||
{
|
||||
await Database.Entry(resource).Collection(x => x.People!).LoadAsync();
|
||||
resource.People = changed.People;
|
||||
}
|
||||
// if (changed.People != null)
|
||||
// {
|
||||
// await Database.Entry(resource).Collection(x => x.People!).LoadAsync();
|
||||
// resource.People = changed.People;
|
||||
// }
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -166,7 +166,7 @@ namespace Kyoo.Core.Api
|
||||
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||
public async Task<ActionResult<T>> Edit([FromBody] T resource)
|
||||
{
|
||||
if (resource.Id != null)
|
||||
if (resource.Id != Guid.Empty)
|
||||
return await Repository.Edit(resource);
|
||||
|
||||
T old = await Repository.Get(resource.Slug);
|
||||
|
@ -33,28 +33,28 @@ namespace Kyoo.Core.Api
|
||||
/// <inheritdoc />
|
||||
public override void WriteJson(JsonWriter writer, PeopleRole? value, JsonSerializer serializer)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
writer.WriteNull();
|
||||
return;
|
||||
}
|
||||
|
||||
ICollection<PeopleRole>? oldPeople = value.Show?.People;
|
||||
ICollection<PeopleRole>? oldRoles = value.People?.Roles;
|
||||
if (value.Show != null)
|
||||
value.Show.People = null;
|
||||
if (value.People != null)
|
||||
value.People.Roles = null;
|
||||
|
||||
JObject obj = JObject.FromObject((value.ForPeople ? value.People : value.Show)!, serializer);
|
||||
obj.Add("role", value.Role);
|
||||
obj.Add("type", value.Type);
|
||||
obj.WriteTo(writer);
|
||||
|
||||
if (value.Show != null)
|
||||
value.Show.People = oldPeople;
|
||||
if (value.People != null)
|
||||
value.People.Roles = oldRoles;
|
||||
// if (value == null)
|
||||
// {
|
||||
// writer.WriteNull();
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// ICollection<PeopleRole>? oldPeople = value.Show?.People;
|
||||
// ICollection<PeopleRole>? oldRoles = value.People?.Roles;
|
||||
// if (value.Show != null)
|
||||
// value.Show.People = null;
|
||||
// if (value.People != null)
|
||||
// value.People.Roles = null;
|
||||
//
|
||||
// JObject obj = JObject.FromObject((value.ForPeople ? value.People : value.Show)!, serializer);
|
||||
// obj.Add("role", value.Role);
|
||||
// obj.Add("type", value.Type);
|
||||
// obj.WriteTo(writer);
|
||||
//
|
||||
// if (value.Show != null)
|
||||
// value.Show.People = oldPeople;
|
||||
// if (value.People != null)
|
||||
// value.People.Roles = oldRoles;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
@ -72,10 +72,10 @@ namespace Kyoo.Postgresql
|
||||
/// </summary>
|
||||
public DbSet<Episode> Episodes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All people of Kyoo. See <see cref="People"/>.
|
||||
/// </summary>
|
||||
public DbSet<People> People { get; set; }
|
||||
// /// <summary>
|
||||
// /// All people of Kyoo. See <see cref="People"/>.
|
||||
// /// </summary>
|
||||
// public DbSet<People> People { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All studios of Kyoo. See <see cref="Studio"/>.
|
||||
@ -87,10 +87,10 @@ namespace Kyoo.Postgresql
|
||||
/// </summary>
|
||||
public DbSet<User> Users { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All people's role. See <see cref="PeopleRole"/>.
|
||||
/// </summary>
|
||||
public DbSet<PeopleRole> PeopleRoles { get; set; }
|
||||
// /// <summary>
|
||||
// /// All people's role. See <see cref="PeopleRole"/>.
|
||||
// /// </summary>
|
||||
// public DbSet<PeopleRole> PeopleRoles { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Add a many to many link between two resources.
|
||||
@ -243,9 +243,8 @@ namespace Kyoo.Postgresql
|
||||
.Ignore(x => x.PreviousEpisode)
|
||||
.Ignore(x => x.NextEpisode);
|
||||
|
||||
modelBuilder.Entity<PeopleRole>()
|
||||
.Ignore(x => x.ForPeople);
|
||||
|
||||
// modelBuilder.Entity<PeopleRole>()
|
||||
// .Ignore(x => x.ForPeople);
|
||||
modelBuilder.Entity<Show>()
|
||||
.HasMany(x => x.Seasons)
|
||||
.WithOne(x => x.Show)
|
||||
@ -271,17 +270,12 @@ namespace Kyoo.Postgresql
|
||||
_HasManyToMany<Collection, Movie>(modelBuilder, x => x.Movies, x => x.Collections);
|
||||
_HasManyToMany<Collection, Show>(modelBuilder, x => x.Shows, x => x.Collections);
|
||||
|
||||
modelBuilder.Entity<User>()
|
||||
.HasMany(x => x.Watched)
|
||||
.WithMany("Users")
|
||||
.UsingEntity(x => x.ToTable(LinkName<User, Show>()));
|
||||
|
||||
_HasMetadata<Collection>(modelBuilder);
|
||||
_HasMetadata<Movie>(modelBuilder);
|
||||
_HasMetadata<Show>(modelBuilder);
|
||||
_HasMetadata<Season>(modelBuilder);
|
||||
_HasMetadata<Episode>(modelBuilder);
|
||||
_HasMetadata<People>(modelBuilder);
|
||||
// _HasMetadata<People>(modelBuilder);
|
||||
_HasMetadata<Studio>(modelBuilder);
|
||||
|
||||
_HasImages<Collection>(modelBuilder);
|
||||
@ -289,7 +283,7 @@ namespace Kyoo.Postgresql
|
||||
_HasImages<Show>(modelBuilder);
|
||||
_HasImages<Season>(modelBuilder);
|
||||
_HasImages<Episode>(modelBuilder);
|
||||
_HasImages<People>(modelBuilder);
|
||||
// _HasImages<People>(modelBuilder);
|
||||
|
||||
_HasAddedDate<Collection>(modelBuilder);
|
||||
_HasAddedDate<Movie>(modelBuilder);
|
||||
@ -300,15 +294,12 @@ namespace Kyoo.Postgresql
|
||||
|
||||
modelBuilder.Entity<User>().OwnsOne(x => x.Logo);
|
||||
|
||||
modelBuilder.Entity<WatchedEpisode>()
|
||||
.HasKey(x => new { User = x.UserID, Episode = x.EpisodeID });
|
||||
|
||||
modelBuilder.Entity<Collection>()
|
||||
.HasIndex(x => x.Slug)
|
||||
.IsUnique();
|
||||
modelBuilder.Entity<People>()
|
||||
.HasIndex(x => x.Slug)
|
||||
.IsUnique();
|
||||
// modelBuilder.Entity<People>()
|
||||
// .HasIndex(x => x.Slug)
|
||||
// .IsUnique();
|
||||
modelBuilder.Entity<Movie>()
|
||||
.HasIndex(x => x.Slug)
|
||||
.IsUnique();
|
||||
|
Loading…
x
Reference in New Issue
Block a user