Fixed a bunch of bugs in Ombi #865

This commit is contained in:
tidusjar 2017-09-01 22:41:56 +01:00
parent 496e086e32
commit 42f48caf3b
9 changed files with 40 additions and 15 deletions

View file

@ -63,7 +63,7 @@ namespace Ombi.Core.Engine
if (result != null) if (result != null)
{ {
Logger.LogDebug("Search Result: {result}", result); Logger.LogDebug("Search Result: {result}", result);
return await TransformMovieResultsToResponse(result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API
} }
} }
@ -81,7 +81,7 @@ namespace Ombi.Core.Engine
if (result != null) if (result != null)
{ {
Logger.LogDebug("Search Result: {result}", result); Logger.LogDebug("Search Result: {result}", result);
return await TransformMovieResultsToResponse(result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API
} }
return null; return null;
} }
@ -96,7 +96,7 @@ namespace Ombi.Core.Engine
if (result != null) if (result != null)
{ {
Logger.LogDebug("Search Result: {result}", result); Logger.LogDebug("Search Result: {result}", result);
return await TransformMovieResultsToResponse(result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API
} }
return null; return null;
} }
@ -111,7 +111,7 @@ namespace Ombi.Core.Engine
if (result != null) if (result != null)
{ {
Logger.LogDebug("Search Result: {result}", result); Logger.LogDebug("Search Result: {result}", result);
return await TransformMovieResultsToResponse(result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API
} }
return null; return null;
} }
@ -126,7 +126,7 @@ namespace Ombi.Core.Engine
if (result != null) if (result != null)
{ {
Logger.LogDebug("Search Result: {result}", result); Logger.LogDebug("Search Result: {result}", result);
return await TransformMovieResultsToResponse(result); return await TransformMovieResultsToResponse(result.Take(10)); // Take 10 to stop us overloading the API
} }
return null; return null;
} }

View file

@ -149,8 +149,6 @@
</tr> </tr>
<tr> <tr>
<td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top"> <td style="font-family: sans-serif; font-size: 14px; vertical-align: top;" valign="top">
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">Hi there!</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{@SUBJECT}</p>
<p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{@BODY}</p> <p style="font-family: sans-serif; font-size: 14px; font-weight: normal; margin: 0; Margin-bottom: 15px;">{@BODY}</p>
</td> </td>

View file

@ -1,6 +1,12 @@
using System.Linq; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Ombi.Core.Notifications;
using Ombi.Helpers;
using Ombi.Notifications.Models;
using Ombi.Store.Entities;
using Ombi.Store.Repository; using Ombi.Store.Repository;
using Ombi.Store.Repository.Requests; using Ombi.Store.Repository.Requests;
@ -8,16 +14,19 @@ namespace Ombi.Schedule.Jobs.Plex
{ {
public class PlexAvailabilityChecker : IPlexAvailabilityChecker public class PlexAvailabilityChecker : IPlexAvailabilityChecker
{ {
public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies) public PlexAvailabilityChecker(IPlexContentRepository repo, ITvRequestRepository tvRequest, IMovieRequestRepository movies,
INotificationService notification)
{ {
_tvRepo = tvRequest; _tvRepo = tvRequest;
_repo = repo; _repo = repo;
_movieRepo = movies; _movieRepo = movies;
_notificationService = notification;
} }
private readonly ITvRequestRepository _tvRepo; private readonly ITvRequestRepository _tvRepo;
private readonly IMovieRequestRepository _movieRepo; private readonly IMovieRequestRepository _movieRepo;
private readonly IPlexContentRepository _repo; private readonly IPlexContentRepository _repo;
private readonly INotificationService _notificationService;
public async Task Start() public async Task Start()
{ {
@ -55,6 +64,13 @@ namespace Ombi.Schedule.Jobs.Plex
{ {
// We have fulfulled this request! // We have fulfulled this request!
child.Available = true; child.Available = true;
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
{
DateTime = DateTime.Now,
NotificationType = NotificationType.RequestAvailable,
RequestId = child.ParentRequestId,
RequestType = RequestType.TvShow
}));
} }
} }
@ -76,6 +92,16 @@ namespace Ombi.Schedule.Jobs.Plex
} }
movie.Available = true; movie.Available = true;
if (movie.Available)
{
BackgroundJob.Enqueue(() => _notificationService.Publish(new NotificationOptions
{
DateTime = DateTime.Now,
NotificationType = NotificationType.RequestAvailable,
RequestId = movie.Id,
RequestType = RequestType.Movie
}));
}
} }
await _movieRepo.Save(); await _movieRepo.Save();

View file

@ -41,7 +41,7 @@ namespace Ombi.Schedule.Jobs.Radarr
if (movies != null) if (movies != null)
{ {
// Let's remove the old cached data // Let's remove the old cached data
await _ctx.Database.ExecuteSqlCommandAsync("TRUNCATE TABLE RadarrCache"); await _ctx.Database.ExecuteSqlCommandAsync("DELETE FROM RadarrCache");
var movieIds = new List<RadarrCache>(); var movieIds = new List<RadarrCache>();
foreach (var m in movies) foreach (var m in movies)

View file

@ -22,6 +22,7 @@
<ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" /> <ProjectReference Include="..\Ombi.Api.Plex\Ombi.Api.Plex.csproj" />
<ProjectReference Include="..\Ombi.Api.Radarr\Ombi.Api.Radarr.csproj" /> <ProjectReference Include="..\Ombi.Api.Radarr\Ombi.Api.Radarr.csproj" />
<ProjectReference Include="..\Ombi.Api.Service\Ombi.Api.Service.csproj" /> <ProjectReference Include="..\Ombi.Api.Service\Ombi.Api.Service.csproj" />
<ProjectReference Include="..\Ombi.Notifications\Ombi.Notifications.csproj" />
<ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" /> <ProjectReference Include="..\Ombi.Settings\Ombi.Settings.csproj" />
</ItemGroup> </ItemGroup>

View file

@ -34,7 +34,7 @@ export class AuthService extends ServiceHelpers {
} }
var json = this.jwtHelper.decodeToken(token); var json = this.jwtHelper.decodeToken(token);
var roles = json["role"]; var roles = json["role"];
var name = json["name"]; var name = json["sub"];
var u = { name: name, roles: [] as string[] }; var u = { name: name, roles: [] as string[] };

View file

@ -86,7 +86,7 @@
</div> </div>
</div> </div>
<div *ngIf="!result.available"> <div *ngIf="!result.available">
<div *ngIf="result.requested; then requestedBtn else notRequestedBtn"></div> <div *ngIf="result.requested || result.approved; then requestedBtn else notRequestedBtn"></div>
<ng-template #requestedBtn> <ng-template #requestedBtn>
<button style="text-align: right" class="btn btn-primary-outline disabled" [disabled]><i class="fa fa-check"></i> Requested</button> <button style="text-align: right" class="btn btn-primary-outline disabled" [disabled]><i class="fa fa-check"></i> Requested</button>
</ng-template> </ng-template>

View file

@ -25,12 +25,12 @@
</div> </div>
<div class="form-group"> <!--<div class="form-group">
<div class="checkbox"> <div class="checkbox">
<input type="checkbox" id="enable" name="enable" [(ngModel)]="settings.timeLimit" ng-checked="settings.timeLimit"> <input type="checkbox" id="enable" name="enable" [(ngModel)]="settings.timeLimit" ng-checked="settings.timeLimit">
<label for="enable">Only show the notification message between the below times</label> <label for="enable">Only show the notification message between the below times</label>
</div> </div>
</div> </div>-->

View file

@ -90,7 +90,7 @@
<label for="rootFolders" class="control-label">Default Root Folders</label> <label for="rootFolders" class="control-label">Default Root Folders</label>
<div id="rootFolders"> <div id="rootFolders">
<select formControlName="defaultRootPath" class="form-control form-control-custom"> <select formControlName="defaultRootPath" class="form-control form-control-custom">
<option *ngFor='let folder of rootFolders' value='{{folder.id}}'>{{folder.path}}</option> <option *ngFor='let folder of rootFolders' value='{{folder.path}}'>{{folder.path}}</option>
</select> </select>
</div> </div>
</div> </div>