From 062ba2419b8bb0753173ff750736558a77bd99b4 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Mon, 22 Jun 2020 21:41:58 +0100 Subject: [PATCH] Fixed the duplicate notifications --- src/Ombi.Helpers/OmbiQuartz.cs | 17 +++++++- .../Jobs/Ombi/Interfaces/IssuesPurge.cs | 3 +- .../Jobs/Plex/PlexContentSync.cs | 29 ++------------ .../movie/movie-details.component.html | 4 +- .../movie/movie-details.component.ts | 39 +++++++++++-------- .../movie-information-panel.component.html | 4 +- .../movie-information-panel.component.ts | 4 +- 7 files changed, 49 insertions(+), 51 deletions(-) diff --git a/src/Ombi.Helpers/OmbiQuartz.cs b/src/Ombi.Helpers/OmbiQuartz.cs index 4309a4c53..573bd6262 100644 --- a/src/Ombi.Helpers/OmbiQuartz.cs +++ b/src/Ombi.Helpers/OmbiQuartz.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using Quartz; using Quartz.Impl; @@ -15,6 +16,8 @@ namespace Ombi.Helpers public static IScheduler Scheduler => Instance._scheduler; + private static SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1); + // Singleton protected static OmbiQuartz _instance; @@ -84,10 +87,20 @@ namespace Ombi.Helpers public static async Task TriggerJob(string jobName, string group) { - if (!(await IsJobRunning(jobName))) + await _semaphore.WaitAsync(); + + try { - await Scheduler.TriggerJob(new JobKey(jobName, group)); + if (!(await IsJobRunning(jobName))) + { + await Scheduler.TriggerJob(new JobKey(jobName, group)); + } } + finally + { + _semaphore.Release(); + } + } diff --git a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs index e4ae2a42e..6b810e9b3 100644 --- a/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs +++ b/src/Ombi.Schedule/Jobs/Ombi/Interfaces/IssuesPurge.cs @@ -1,6 +1,7 @@ using System; using System.Linq; using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; using Ombi.Core.Settings; using Ombi.Settings.Settings.Models; using Ombi.Store.Entities.Requests; @@ -31,7 +32,7 @@ namespace Ombi.Schedule.Jobs.Ombi var today = DateTime.UtcNow.Date; - var resolved = _issuesRepository.GetAll().Where(x => x.Status == IssueStatus.Resolved); + var resolved = await _issuesRepository.GetAll().Where(x => x.Status == IssueStatus.Resolved).ToListAsync(); var toDelete = resolved.Where(x => x.ResovledDate.HasValue && (today - x.ResovledDate.Value.Date).TotalDays >= settings.DaysAfterResolvedToDelete); foreach (var d in toDelete) diff --git a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs index e3f0ee30b..661b79a27 100644 --- a/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs +++ b/src/Ombi.Schedule/Jobs/Plex/PlexContentSync.cs @@ -115,34 +115,13 @@ namespace Ombi.Schedule.Jobs.Plex if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch) { - // Ensure it's not already running - if (await OmbiQuartz.IsJobRunning(nameof(IPlexAvailabilityChecker))) - { - Logger.LogInformation("Availability checker already running"); - } - else - { - await NotifyClient("Plex Sync - Checking if any requests are now available"); - Logger.LogInformation("Kicking off Plex Availability Checker"); - await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex"); - } - } - - if ((processedContent?.HasProcessedContent ?? false) && recentlyAddedSearch) - { - // Ensure it's not already running - if (await OmbiQuartz.IsJobRunning(nameof(IPlexAvailabilityChecker))) - { - Logger.LogInformation("Availability checker already running"); - } - else - { - await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex"); - } + await NotifyClient("Plex Sync - Checking if any requests are now available"); + Logger.LogInformation("Kicking off Plex Availability Checker"); + await OmbiQuartz.TriggerJob(nameof(IPlexAvailabilityChecker), "Plex"); } var processedCont = processedContent?.Content?.Count() ?? 0; var processedEp = processedContent?.Episodes?.Count() ?? 0; - Logger.LogInformation("Finished Plex Content Cacher, with processed content: {0}, episodes: {1}. Recently Added Scan: {2}", processedContent, processedEp, recentlyAddedSearch); + Logger.LogInformation("Finished Plex Content Cacher, with processed content: {0}, episodes: {1}. Recently Added Scan: {2}", processedCont, processedEp, recentlyAddedSearch); await NotifyClient(recentlyAddedSearch ? $"Plex Recently Added Sync Finished, We processed {processedCont}, and {processedEp} Episodes" : "Plex Content Sync Finished"); diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html index 51006ca9a..a59294955 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.html @@ -76,14 +76,14 @@
- + - + diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts index 65ac449aa..8d8704511 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/movie-details.component.ts @@ -33,14 +33,13 @@ export class MovieDetailsComponent { public messageService: MessageService, private auth: AuthService, private storage: StorageService) { this.route.params.subscribe((params: any) => { - debugger; - if (typeof params.movieDbId === 'string' || params.movieDbId instanceof String) { - if (params.movieDbId.startsWith("tt")) { - this.imdbId = params.movieDbId; - } + if (typeof params.movieDbId === 'string' || params.movieDbId instanceof String) { + if (params.movieDbId.startsWith("tt")) { + this.imdbId = params.movieDbId; } - this.theMovidDbId = params.movieDbId; - this.load(); + } + this.theMovidDbId = params.movieDbId; + this.load(); }); } @@ -97,22 +96,22 @@ export class MovieDetailsComponent { public async deny() { const dialogRef = this.dialog.open(DenyDialogComponent, { width: '250px', - data: {requestId: this.movieRequest.id, requestType: RequestType.movie} - }); - - dialogRef.afterClosed().subscribe(result => { + data: { requestId: this.movieRequest.id, requestType: RequestType.movie } + }); + + dialogRef.afterClosed().subscribe(result => { this.movieRequest.denied = result; - if(this.movieRequest.denied) { + if (this.movieRequest.denied) { this.movie.approved = false; } - }); + }); } public async issue() { const dialogRef = this.dialog.open(NewIssueComponent, { width: '500px', - data: {requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, providerId: this.movie.imdbId ? this.movie.imdbId : this.movie.id, title: this.movie.title} - }); + data: { requestId: this.movieRequest ? this.movieRequest.id : null, requestType: RequestType.movie, providerId: this.movie.imdbId ? this.movie.imdbId : this.movie.id, title: this.movie.title } + }); } public async approve() { @@ -126,7 +125,7 @@ export class MovieDetailsComponent { } public async markAvailable() { - const result = await this.requestService.markMovieAvailable({id: this.movieRequest.id}).toPromise(); + const result = await this.requestService.markMovieAvailable({ id: this.movieRequest.id }).toPromise(); if (result.result) { this.movie.available = true; this.messageService.send(result.message, "Ok"); @@ -135,7 +134,13 @@ export class MovieDetailsComponent { } } - public setAdvancedOptions(data: any) { + public setAdvancedOptions(data: IAdvancedData) { this.advancedOptions = data; + if (data.rootFolderId) { + this.movieRequest.qualityOverrideTitle = data.rootFolders.filter(x => x.id == data.rootFolderId)[0].path; + } + if (data.profileId) { + this.movieRequest.rootPathOverrideTitle = data.profiles.filter(x => x.id == data.profileId)[0].name; + } } } diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html index 8c9f73baf..449dd09c4 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.html @@ -25,11 +25,11 @@
{{'MediaDetails.RootFolderOverride' | translate }} -
{{advancedOptions.rootFolder.path}}
+
{{request.rootPathOverrideTitle}}
{{'MediaDetails.QualityOverride' | translate }} -
{{advancedOptions.profile.name}}
+
{{request.qualityOverrideTitle}}

diff --git a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts index 64b458de4..af972b0e4 100644 --- a/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts +++ b/src/Ombi/ClientApp/src/app/media-details/components/movie/panels/movie-information-panel.component.ts @@ -1,6 +1,6 @@ import { Component, ViewEncapsulation, Input } from "@angular/core"; import { ISearchMovieResultV2 } from "../../../../interfaces/ISearchMovieResultV2"; -import { IAdvancedData } from "../../../../interfaces"; +import { IAdvancedData, IMovieRequests } from "../../../../interfaces"; @Component({ templateUrl: "./movie-information-panel.component.html", @@ -10,5 +10,5 @@ import { IAdvancedData } from "../../../../interfaces"; }) export class MovieInformationPanelComponent { @Input() public movie: ISearchMovieResultV2; - @Input() public advancedOptions: IAdvancedData; + @Input() public request: IMovieRequests; }