mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-24 06:55:23 -07:00
Display played state in the requests list
This commit is contained in:
parent
eedc8753c3
commit
84c02ae436
6 changed files with 60 additions and 11 deletions
|
@ -33,7 +33,8 @@ namespace Ombi.Core.Engine
|
||||||
INotificationHelper helper, IRuleEvaluator r, IMovieSender sender, ILogger<MovieRequestEngine> log,
|
INotificationHelper helper, IRuleEvaluator r, IMovieSender sender, ILogger<MovieRequestEngine> log,
|
||||||
OmbiUserManager manager, IRepository<RequestLog> rl, ICacheService cache,
|
OmbiUserManager manager, IRepository<RequestLog> rl, ICacheService cache,
|
||||||
ISettingsService<OmbiSettings> ombiSettings, IRepository<RequestSubscription> sub, IMediaCacheService mediaCacheService,
|
ISettingsService<OmbiSettings> ombiSettings, IRepository<RequestSubscription> sub, IMediaCacheService mediaCacheService,
|
||||||
IFeatureService featureService)
|
IFeatureService featureService,
|
||||||
|
IUserPlayedMovieRepository userPlayedMovieRepository)
|
||||||
: base(user, requestService, r, manager, cache, ombiSettings, sub)
|
: base(user, requestService, r, manager, cache, ombiSettings, sub)
|
||||||
{
|
{
|
||||||
MovieApi = movieApi;
|
MovieApi = movieApi;
|
||||||
|
@ -43,6 +44,7 @@ namespace Ombi.Core.Engine
|
||||||
_requestLog = rl;
|
_requestLog = rl;
|
||||||
_mediaCacheService = mediaCacheService;
|
_mediaCacheService = mediaCacheService;
|
||||||
_featureService = featureService;
|
_featureService = featureService;
|
||||||
|
_userPlayedMovieRepository = userPlayedMovieRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMovieDbApi MovieApi { get; }
|
private IMovieDbApi MovieApi { get; }
|
||||||
|
@ -52,6 +54,7 @@ namespace Ombi.Core.Engine
|
||||||
private readonly IRepository<RequestLog> _requestLog;
|
private readonly IRepository<RequestLog> _requestLog;
|
||||||
private readonly IMediaCacheService _mediaCacheService;
|
private readonly IMediaCacheService _mediaCacheService;
|
||||||
private readonly IFeatureService _featureService;
|
private readonly IFeatureService _featureService;
|
||||||
|
protected readonly IUserPlayedMovieRepository _userPlayedMovieRepository;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Requests the movie.
|
/// Requests the movie.
|
||||||
|
@ -252,7 +255,7 @@ namespace Ombi.Core.Engine
|
||||||
var requests = await (OrderMovies(allRequests, orderFilter.OrderType)).Skip(position).Take(count)
|
var requests = await (OrderMovies(allRequests, orderFilter.OrderType)).Skip(position).Take(count)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
await CheckForSubscription(shouldHide.UserId, requests);
|
await FillAdditionalFields(shouldHide.UserId, requests);
|
||||||
return new RequestsViewModel<MovieRequests>
|
return new RequestsViewModel<MovieRequests>
|
||||||
{
|
{
|
||||||
Collection = requests,
|
Collection = requests,
|
||||||
|
@ -296,7 +299,7 @@ namespace Ombi.Core.Engine
|
||||||
var total = requests.Count();
|
var total = requests.Count();
|
||||||
requests = requests.Skip(position).Take(count).ToList();
|
requests = requests.Skip(position).Take(count).ToList();
|
||||||
|
|
||||||
await CheckForSubscription(shouldHide.UserId, requests);
|
await FillAdditionalFields(shouldHide.UserId, requests);
|
||||||
return new RequestsViewModel<MovieRequests>
|
return new RequestsViewModel<MovieRequests>
|
||||||
{
|
{
|
||||||
Collection = requests,
|
Collection = requests,
|
||||||
|
@ -381,7 +384,7 @@ namespace Ombi.Core.Engine
|
||||||
// TODO fix this so we execute this on the server
|
// TODO fix this so we execute this on the server
|
||||||
requests = requests.Skip(position).Take(count).ToList();
|
requests = requests.Skip(position).Take(count).ToList();
|
||||||
|
|
||||||
await CheckForSubscription(shouldHide.UserId, requests);
|
await FillAdditionalFields(shouldHide.UserId, requests);
|
||||||
return new RequestsViewModel<MovieRequests>
|
return new RequestsViewModel<MovieRequests>
|
||||||
{
|
{
|
||||||
Collection = requests,
|
Collection = requests,
|
||||||
|
@ -424,7 +427,7 @@ namespace Ombi.Core.Engine
|
||||||
var total = requests.Count();
|
var total = requests.Count();
|
||||||
requests = requests.Skip(position).Take(count).ToList();
|
requests = requests.Skip(position).Take(count).ToList();
|
||||||
|
|
||||||
await CheckForSubscription(shouldHide.UserId, requests);
|
await FillAdditionalFields(shouldHide.UserId, requests);
|
||||||
return new RequestsViewModel<MovieRequests>
|
return new RequestsViewModel<MovieRequests>
|
||||||
{
|
{
|
||||||
Collection = requests,
|
Collection = requests,
|
||||||
|
@ -506,7 +509,7 @@ namespace Ombi.Core.Engine
|
||||||
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
allRequests = await MovieRepository.GetWithUser().ToListAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
await CheckForSubscription(shouldHide.UserId, allRequests);
|
await FillAdditionalFields(shouldHide.UserId, allRequests);
|
||||||
|
|
||||||
return allRequests;
|
return allRequests;
|
||||||
}
|
}
|
||||||
|
@ -514,10 +517,15 @@ namespace Ombi.Core.Engine
|
||||||
public async Task<MovieRequests> GetRequest(int requestId)
|
public async Task<MovieRequests> GetRequest(int requestId)
|
||||||
{
|
{
|
||||||
var request = await MovieRepository.GetWithUser().Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
var request = await MovieRepository.GetWithUser().Where(x => x.Id == requestId).FirstOrDefaultAsync();
|
||||||
await CheckForSubscription((await GetUser()).Id, new List<MovieRequests> { request });
|
await FillAdditionalFields((await GetUser()).Id, new List<MovieRequests> { request });
|
||||||
|
|
||||||
return request;
|
return request;
|
||||||
}
|
}
|
||||||
|
private async Task FillAdditionalFields(string UserId, List<MovieRequests> requests)
|
||||||
|
{
|
||||||
|
await CheckForSubscription(UserId, requests);
|
||||||
|
await CheckForPlayed(requests);
|
||||||
|
}
|
||||||
|
|
||||||
private async Task CheckForSubscription(string UserId, List<MovieRequests> movieRequests)
|
private async Task CheckForSubscription(string UserId, List<MovieRequests> movieRequests)
|
||||||
{
|
{
|
||||||
|
@ -543,6 +551,19 @@ namespace Ombi.Core.Engine
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task CheckForPlayed(List<MovieRequests> movieRequests)
|
||||||
|
{
|
||||||
|
var theMovieDbIds = movieRequests.Select(x => x.TheMovieDbId);
|
||||||
|
var plays = await _userPlayedMovieRepository.GetAll().Where(x =>
|
||||||
|
theMovieDbIds.Contains(x.TheMovieDbId))
|
||||||
|
.ToListAsync();
|
||||||
|
foreach (var request in movieRequests)
|
||||||
|
{
|
||||||
|
request.WatchedByRequestedUser = plays.Exists(x => x.TheMovieDbId == request.TheMovieDbId && x.UserId == request.RequestedUserId);
|
||||||
|
request.PlayedByUsersCount = plays.Count(x => x.TheMovieDbId == request.TheMovieDbId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Searches the movie request.
|
/// Searches the movie request.
|
||||||
|
@ -563,7 +584,7 @@ namespace Ombi.Core.Engine
|
||||||
}
|
}
|
||||||
|
|
||||||
var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
|
var results = allRequests.Where(x => x.Title.Contains(search, CompareOptions.IgnoreCase)).ToList();
|
||||||
await CheckForSubscription(shouldHide.UserId, results);
|
await FillAdditionalFields(shouldHide.UserId, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,5 +84,10 @@ namespace Ombi.Store.Entities.Requests
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public override bool CanApprove => !Approved && !Available || !Approved4K && !Available4K;
|
public override bool CanApprove => !Approved && !Available || !Approved4K && !Available4K;
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public bool WatchedByRequestedUser { get; set; }
|
||||||
|
[NotMapped]
|
||||||
|
public int PlayedByUsersCount { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ export interface IMovieRequests extends IFullBaseRequest {
|
||||||
deniedReason4K: string;
|
deniedReason4K: string;
|
||||||
requestedDate4k: Date;
|
requestedDate4k: Date;
|
||||||
requestedDate: Date;
|
requestedDate: Date;
|
||||||
|
watchedByRequestedUser: boolean;
|
||||||
|
playedByUsersCount: number;
|
||||||
|
|
||||||
// For the UI
|
// For the UI
|
||||||
rootPathOverrideTitle: string;
|
rootPathOverrideTitle: string;
|
||||||
|
@ -212,4 +214,4 @@ export class BaseRequestOptions {
|
||||||
requestOnBehalf: string | undefined;
|
requestOnBehalf: string | undefined;
|
||||||
rootFolderOverride: number | undefined;
|
rootFolderOverride: number | undefined;
|
||||||
qualityPathOverride: number | undefined;
|
qualityPathOverride: number | undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,24 @@
|
||||||
<td mat-cell id="requestedStatus{{element.id}}" *matCellDef="let element"> {{element.requestStatus | translate}} </td>
|
<td mat-cell id="requestedStatus{{element.id}}" *matCellDef="let element"> {{element.requestStatus | translate}} </td>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="watchedByRequestedUser">
|
||||||
|
<th
|
||||||
|
mat-header-cell
|
||||||
|
*matHeaderCellDef
|
||||||
|
mat-sort-header
|
||||||
|
disableClear
|
||||||
|
matTooltip="{{ 'Requests.WatchedTooltip' | translate}}">
|
||||||
|
{{ 'Requests.Watched' | translate}}
|
||||||
|
</th>
|
||||||
|
<td mat-cell id="watchedByRequestedUser{{element.id}}" *matCellDef="let element">
|
||||||
|
<mat-checkbox
|
||||||
|
[checked]="element.watchedByRequestedUser"
|
||||||
|
disabled="true"
|
||||||
|
matTooltip="{{'Requests.WatchedByUsersCount' | translate: {count: element.playedByUsersCount} }}">
|
||||||
|
</mat-checkbox>
|
||||||
|
</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
<ng-container matColumnDef="actions">
|
<ng-container matColumnDef="actions">
|
||||||
<th mat-header-cell *matHeaderCellDef> </th>
|
<th mat-header-cell *matHeaderCellDef> </th>
|
||||||
<td mat-cell *matCellDef="let element">
|
<td mat-cell *matCellDef="let element">
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
|
||||||
public dataSource: MatTableDataSource<IMovieRequests>;
|
public dataSource: MatTableDataSource<IMovieRequests>;
|
||||||
public resultsLength: number;
|
public resultsLength: number;
|
||||||
public isLoadingResults = true;
|
public isLoadingResults = true;
|
||||||
public displayedColumns: string[] = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate', 'actions'];
|
public displayedColumns: string[] = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate', 'watchedByRequestedUser', 'actions'];
|
||||||
public gridCount: string = "15";
|
public gridCount: string = "15";
|
||||||
public isAdmin: boolean;
|
public isAdmin: boolean;
|
||||||
public is4kEnabled = false;
|
public is4kEnabled = false;
|
||||||
|
@ -263,4 +263,4 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
|
||||||
}
|
}
|
||||||
return request.requestedDate;
|
return request.requestedDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,6 +159,9 @@
|
||||||
"RequestedBy": "Requested By",
|
"RequestedBy": "Requested By",
|
||||||
"Status": "Status",
|
"Status": "Status",
|
||||||
"RequestStatus": "Request status",
|
"RequestStatus": "Request status",
|
||||||
|
"Watched": "Watched",
|
||||||
|
"WatchedTooltip": "The user who made the request has watched it",
|
||||||
|
"WatchedByUsersCount": "{{count}} users have watched this.",
|
||||||
"Denied": " Denied:",
|
"Denied": " Denied:",
|
||||||
"TheatricalRelease": "Theatrical Release: {{date}}",
|
"TheatricalRelease": "Theatrical Release: {{date}}",
|
||||||
"ReleaseDate": "Released: {{date}}",
|
"ReleaseDate": "Released: {{date}}",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue