-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1216 from ShokoAnime/cached_tmdb
Cache core tmdb tables
- Loading branch information
Showing
52 changed files
with
247 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ositories/Cached/AniDB_AnimeRepository.cs → ...ies/Cached/AniDB/AniDB_AnimeRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...Cached/AniDB_Anime_CharacterRepository.cs → .../AniDB/AniDB_Anime_CharacterRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...niDB_Anime_Character_CreatorRepository.cs → ...niDB_Anime_Character_CreatorRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...d/AniDB_Anime_PreferredImageRepository.cs → ...B/AniDB_Anime_PreferredImageRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ories/Cached/AniDB_Anime_TagRepository.cs → ...Cached/AniDB/AniDB_Anime_TagRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...ies/Cached/AniDB_Anime_TitleRepository.cs → ...ched/AniDB/AniDB_Anime_TitleRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ories/Cached/AniDB_CharacterRepository.cs → ...Cached/AniDB/AniDB_CharacterRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...itories/Cached/AniDB_CreatorRepository.cs → ...s/Cached/AniDB/AniDB_CreatorRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...s/Cached/AniDB_Episode_TitleRepository.cs → ...ed/AniDB/AniDB_Episode_TitleRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 3 additions & 4 deletions
7
...positories/Cached/AniDB_FileRepository.cs → ...ries/Cached/AniDB/AniDB_FileRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...epositories/Cached/AniDB_TagRepository.cs → ...ories/Cached/AniDB/AniDB_TagRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
Shoko.Server/Repositories/Cached/TMDB/TMDB_EpisodeRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#nullable enable | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NutzCode.InMemoryIndex; | ||
using Shoko.Server.Databases; | ||
using Shoko.Server.Models.TMDB; | ||
|
||
namespace Shoko.Server.Repositories.Cached.TMDB; | ||
|
||
public class TMDB_EpisodeRepository : BaseCachedRepository<TMDB_Episode, int> | ||
{ | ||
protected override int SelectKey(TMDB_Episode entity) => entity.Id; | ||
private PocoIndex<int, TMDB_Episode, int> _showIDs = null!; | ||
private PocoIndex<int, TMDB_Episode, int> _seasonIDs = null!; | ||
private PocoIndex<int, TMDB_Episode, int> _episodeIDs = null!; | ||
|
||
public override void PopulateIndexes() | ||
{ | ||
_showIDs = Cache.CreateIndex(a => a.TmdbShowID); | ||
_seasonIDs = Cache.CreateIndex(a => a.TmdbSeasonID); | ||
_episodeIDs = Cache.CreateIndex(a => a.TmdbEpisodeID); | ||
} | ||
|
||
public IReadOnlyList<TMDB_Episode> GetByTmdbShowID(int showId) | ||
{ | ||
return _showIDs.GetMultiple(showId).OrderBy(a => a.EpisodeNumber).ToList(); | ||
} | ||
|
||
public IReadOnlyList<TMDB_Episode> GetByTmdbSeasonID(int seasonId) | ||
{ | ||
return _seasonIDs.GetMultiple(seasonId).OrderBy(a => a.EpisodeNumber).ToList(); | ||
} | ||
|
||
public TMDB_Episode? GetByTmdbEpisodeID(int episodeId) | ||
{ | ||
return _episodeIDs.GetOne(episodeId); | ||
} | ||
|
||
public TMDB_EpisodeRepository(DatabaseFactory databaseFactory) : base(databaseFactory) | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
Shoko.Server/Repositories/Cached/TMDB/TMDB_MovieRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#nullable enable | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NutzCode.InMemoryIndex; | ||
using Shoko.Server.Databases; | ||
using Shoko.Server.Models.TMDB; | ||
|
||
namespace Shoko.Server.Repositories.Cached.TMDB; | ||
|
||
public class TMDB_MovieRepository : BaseCachedRepository<TMDB_Movie, int> | ||
{ | ||
protected override int SelectKey(TMDB_Movie entity) => entity.Id; | ||
private PocoIndex<int, TMDB_Movie, int> _movieIDs = null!; | ||
private PocoIndex<int, TMDB_Movie, int?> _collectionIDs = null!; | ||
|
||
public override void PopulateIndexes() | ||
{ | ||
_movieIDs = Cache.CreateIndex(a => a.TmdbMovieID); | ||
_collectionIDs = Cache.CreateIndex(a => a.TmdbCollectionID); | ||
} | ||
|
||
public TMDB_Movie? GetByTmdbMovieID(int tmdbMovieId) | ||
{ | ||
return _movieIDs.GetOne(tmdbMovieId); | ||
} | ||
|
||
public IReadOnlyList<TMDB_Movie> GetByTmdbCollectionID(int tmdbCollectionId) | ||
{ | ||
return _collectionIDs.GetMultiple(tmdbCollectionId).OrderBy(a => a.EnglishTitle) | ||
.ThenBy(a => a.TmdbMovieID) | ||
.ToList(); | ||
} | ||
|
||
public TMDB_MovieRepository(DatabaseFactory databaseFactory) : base(databaseFactory) | ||
{ | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Shoko.Server/Repositories/Cached/TMDB/TMDB_SeasonRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#nullable enable | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using NutzCode.InMemoryIndex; | ||
using Shoko.Server.Databases; | ||
using Shoko.Server.Models.TMDB; | ||
|
||
namespace Shoko.Server.Repositories.Cached.TMDB; | ||
|
||
public class TMDB_SeasonRepository : BaseCachedRepository<TMDB_Season, int> | ||
{ | ||
protected override int SelectKey(TMDB_Season entity) => entity.Id; | ||
private PocoIndex<int, TMDB_Season, int> _showIDs = null!; | ||
private PocoIndex<int, TMDB_Season, int> _seasonIDs = null!; | ||
|
||
public override void PopulateIndexes() | ||
{ | ||
_showIDs = Cache.CreateIndex(a => a.TmdbShowID); | ||
_seasonIDs = Cache.CreateIndex(a => a.TmdbSeasonID); | ||
} | ||
|
||
public IReadOnlyList<TMDB_Season> GetByTmdbShowID(int tmdbShowId) | ||
{ | ||
return _showIDs.GetMultiple(tmdbShowId) | ||
.OrderBy(e => e.SeasonNumber == 0) | ||
.ThenBy(e => e.SeasonNumber) | ||
.ToList(); | ||
} | ||
|
||
public TMDB_Season? GetByTmdbSeasonID(int tmdbSeasonId) | ||
{ | ||
return _seasonIDs.GetOne(tmdbSeasonId); | ||
} | ||
|
||
public TMDB_SeasonRepository(DatabaseFactory databaseFactory) : base(databaseFactory) | ||
{ | ||
} | ||
} |
Oops, something went wrong.