Fixed Series Relations Schema (#1654)

* Bump loader-utils from 2.0.2 to 2.0.3 in /UI/Web

Bumps [loader-utils](https://github.com/webpack/loader-utils) from 2.0.2 to 2.0.3.
- [Release notes](https://github.com/webpack/loader-utils/releases)
- [Changelog](https://github.com/webpack/loader-utils/blob/v2.0.3/CHANGELOG.md)
- [Commits](https://github.com/webpack/loader-utils/compare/v2.0.2...v2.0.3)

---
updated-dependencies:
- dependency-name: loader-utils
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fixed is want to read coming back as a string and not working correctly.

* Changed from to Continue to be more explicit

* Added the first migration which exports data as a csv in temp/. This is the backup in case data is lost in the migration.

* Note for later

* Fixed the migration for the series relation so when deleting any series on any edge of the relationship, the SeriesRelation row deletes.

* Change buttons back to titles on series detail page

* Wrote the code to import relations from the backup.

* Added an additional version check to avoid file io on migration.

* Code cleanup

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
This commit is contained in:
Joe Milazzo 2022-11-15 08:45:02 -06:00 committed by GitHub
parent d5a7c31c7d
commit 15e09a0cf1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 2111 additions and 83 deletions

View file

@ -1257,15 +1257,6 @@ public class SeriesRepository : ISeriesRepository
.Where(s => !ids.Contains(s.Id))
.ToListAsync();
// If the series to remove has Relation (related series), we must manually unlink due to the DB not being
// setup correctly (if this is not done, a foreign key constraint will be thrown)
foreach (var sr in seriesToRemove)
{
sr.Relations = new List<SeriesRelation>();
Update(sr);
}
_context.Series.RemoveRange(seriesToRemove);
return seriesToRemove;
@ -1387,14 +1378,26 @@ public class SeriesRepository : ISeriesRepository
AlternativeSettings = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.AlternativeSetting, userRating),
AlternativeVersions = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.AlternativeVersion, userRating),
Doujinshis = await GetRelatedSeriesQuery(seriesId, usersSeriesIds, RelationKind.Doujinshi, userRating),
Parent = await _context.Series
.SelectMany(s =>
s.RelationOf.Where(r => r.TargetSeriesId == seriesId
&& usersSeriesIds.Contains(r.TargetSeriesId)
&& r.RelationKind != RelationKind.Prequel
&& r.RelationKind != RelationKind.Sequel
&& r.RelationKind != RelationKind.Edition)
.Select(sr => sr.Series))
// Parent = await _context.Series
// .SelectMany(s =>
// s.TargetSeries.Where(r => r.TargetSeriesId == seriesId
// && usersSeriesIds.Contains(r.TargetSeriesId)
// && r.RelationKind != RelationKind.Prequel
// && r.RelationKind != RelationKind.Sequel
// && r.RelationKind != RelationKind.Edition)
// .Select(sr => sr.Series))
// .RestrictAgainstAgeRestriction(userRating)
// .AsSplitQuery()
// .AsNoTracking()
// .ProjectTo<SeriesDto>(_mapper.ConfigurationProvider)
// .ToListAsync(),
Parent = await _context.SeriesRelation
.Where(r => r.TargetSeriesId == seriesId
&& usersSeriesIds.Contains(r.TargetSeriesId)
&& r.RelationKind != RelationKind.Prequel
&& r.RelationKind != RelationKind.Sequel
&& r.RelationKind != RelationKind.Edition)
.Select(sr => sr.Series)
.RestrictAgainstAgeRestriction(userRating)
.AsSplitQuery()
.AsNoTracking()
@ -1477,13 +1480,14 @@ public class SeriesRepository : ISeriesRepository
public async Task<bool> IsSeriesInWantToRead(int userId, int seriesId)
{
// BUG: This is always returning true for any series
var libraryIds = GetLibraryIdsForUser(userId);
return await _context.AppUser
.Where(user => user.Id == userId)
.SelectMany(u => u.WantToRead)
.SelectMany(u => u.WantToRead.Where(s => s.Id == seriesId && libraryIds.Contains(s.LibraryId)))
.AsSplitQuery()
.AsNoTracking()
.AnyAsync(s => libraryIds.Contains(s.LibraryId) && s.Id == seriesId);
.AnyAsync();
}
public async Task<IDictionary<string, IList<SeriesModified>>> GetFolderPathMap(int libraryId)