Add a toggle to activate played sync

pull/4881/head
sephrat 1 year ago
parent 77ce52e68a
commit 925fcd12c7

@ -8,10 +8,12 @@ using Ombi.Api.Emby;
using Ombi.Api.Emby.Models;
using Ombi.Api.Emby.Models.Media.Tv;
using Ombi.Api.Emby.Models.Movie;
using Ombi.Core.Services;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Hubs;
using Ombi.Settings.Settings.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository;
using Quartz;
@ -21,14 +23,20 @@ namespace Ombi.Schedule.Jobs.Emby
{
public class EmbyContentSync : EmbyLibrarySync, IEmbyContentSync
{
public EmbyContentSync(ISettingsService<EmbySettings> settings, IEmbyApiFactory api, ILogger<EmbyContentSync> logger,
IEmbyContentRepository repo, INotificationHubService notification):
public EmbyContentSync(
ISettingsService<EmbySettings> settings,
IEmbyApiFactory api,
ILogger<EmbyContentSync> logger,
IEmbyContentRepository repo,
INotificationHubService notification,
IFeatureService feature):
base(settings, api, logger, notification)
{
_repo = repo;
}
private readonly IEmbyContentRepository _repo;
private readonly IFeatureService _feature;
public async override Task Execute(IJobExecutionContext context)
@ -38,6 +46,13 @@ namespace Ombi.Schedule.Jobs.Emby
// Episodes
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyEpisodeSync), "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, recentlyAdded.ToString() } }));
// Played state
var isPlayedSyncEnabled = await _feature.FeatureEnabled(FeatureNames.PlayedSync);
if(isPlayedSyncEnabled)
{
await OmbiQuartz.Scheduler.TriggerJob(new JobKey(nameof(IEmbyPlayedSync), "Emby"), new JobDataMap(new Dictionary<string, string> { { JobDataKeys.EmbyRecentlyAddedSearch, recentlyAdded.ToString() } }));
}
}

@ -15,15 +15,22 @@ namespace Ombi.Schedule.Jobs.Ombi
{
public class MediaDatabaseRefresh : IMediaDatabaseRefresh
{
public MediaDatabaseRefresh(ISettingsService<PlexSettings> s, ILogger<MediaDatabaseRefresh> log,
IPlexContentRepository plexRepo, IEmbyContentRepository embyRepo, IJellyfinContentRepository jellyfinRepo,
ISettingsService<EmbySettings> embySettings, ISettingsService<JellyfinSettings> jellyfinSettings)
public MediaDatabaseRefresh(
ISettingsService<PlexSettings> s,
ILogger<MediaDatabaseRefresh> log,
IPlexContentRepository plexRepo,
IEmbyContentRepository embyRepo,
IJellyfinContentRepository jellyfinRepo,
IUserPlayedMovieRepository userPlayedRepo,
ISettingsService<EmbySettings> embySettings,
ISettingsService<JellyfinSettings> jellyfinSettings)
{
_plexSettings = s;
_log = log;
_plexRepo = plexRepo;
_embyRepo = embyRepo;
_jellyfinRepo = jellyfinRepo;
_userPlayedRepo = userPlayedRepo;
_embySettings = embySettings;
_jellyfinSettings = jellyfinSettings;
_plexSettings.ClearCache();
@ -34,6 +41,7 @@ namespace Ombi.Schedule.Jobs.Ombi
private readonly IPlexContentRepository _plexRepo;
private readonly IEmbyContentRepository _embyRepo;
private readonly IJellyfinContentRepository _jellyfinRepo;
private readonly IUserPlayedMovieRepository _userPlayedRepo;
private readonly ISettingsService<EmbySettings> _embySettings;
private readonly ISettingsService<JellyfinSettings> _jellyfinSettings;
@ -41,6 +49,7 @@ namespace Ombi.Schedule.Jobs.Ombi
{
try
{
await RemovePlayedData();
await RemovePlexData();
await RemoveEmbyData();
await RemoveJellyfinData();
@ -52,6 +61,20 @@ namespace Ombi.Schedule.Jobs.Ombi
}
private async Task RemovePlayedData()
{
try
{
const string movieSql = "DELETE FROM UserPlayedMovie";
await _userPlayedRepo.ExecuteSql(movieSql);
}
catch (Exception e)
{
_log.LogError(LoggingEvents.MediaReferesh, e, "Refreshing Played Data Failed");
}
}
private async Task RemoveEmbyData()
{
try

@ -21,5 +21,6 @@ namespace Ombi.Settings.Settings.Models
{
public const string Movie4KRequests = nameof(Movie4KRequests);
public const string OldTrendingSource = nameof(OldTrendingSource);
public const string PlayedSync = nameof(PlayedSync);
}
}

@ -24,10 +24,11 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
public dataSource: MatTableDataSource<IMovieRequests>;
public resultsLength: number;
public isLoadingResults = true;
public displayedColumns: string[] = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate', 'watchedByRequestedUser', 'actions'];
public displayedColumns: string[] = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate'];
public gridCount: string = "15";
public isAdmin: boolean;
public is4kEnabled = false;
public isPlayedSyncEnabled = false;
public manageOwnRequests: boolean;
public defaultSort: string = "requestedDate";
public defaultOrder: string = "desc";
@ -65,10 +66,9 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
}
this.is4kEnabled = this.featureFacade.is4kEnabled();
if ((this.isAdmin || this.auth.hasRole("Request4KMovie"))
&& this.is4kEnabled) {
this.displayedColumns.splice(4, 0, 'has4kRequest');
}
this.isPlayedSyncEnabled = this.featureFacade.isPlayedSyncEnabled();
this.addDynamicColumns();
const defaultCount = this.storageService.get(this.storageKeyGridCount);
const defaultSort = this.storageService.get(this.storageKey);
@ -88,6 +88,20 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
}
}
addDynamicColumns() {
if ((this.isAdmin || this.auth.hasRole("Request4KMovie"))
&& this.is4kEnabled) {
this.displayedColumns.splice(4, 0, 'has4kRequest');
}
if (this.isPlayedSyncEnabled) {
this.displayedColumns.push('watchedByRequestedUser');
}
// always put the actions column at the end
this.displayedColumns.push('actions');
}
public async ngAfterViewInit() {
this.storageService.save(this.storageKeyGridCount, this.gridCount);

@ -23,4 +23,6 @@ export class FeaturesFacade {
public is4kEnabled = (): boolean => this.store.selectSnapshot(FeaturesSelectors.is4kEnabled);
}
public isPlayedSyncEnabled = (): boolean => this.store.selectSnapshot(FeaturesSelectors.isPlayedSyncEnabled);
}

@ -15,4 +15,9 @@ export class FeaturesSelectors {
return features.filter(x => x.name === "Movie4KRequests")[0].enabled;
}
}
@Selector([FeaturesSelectors.features])
public static isPlayedSyncEnabled(features: IFeatureEnablement[]): boolean {
return features.filter(x => x.name === "PlayedSync")[0].enabled;
}
}

Loading…
Cancel
Save