mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 05:13:18 -07:00
more wip on the issues
This commit is contained in:
parent
b7bb0869da
commit
1289b840a0
11 changed files with 141 additions and 37 deletions
|
@ -3,6 +3,7 @@ using Ombi.Store.Entities.Requests;
|
|||
using Ombi.Store.Repository;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Ombi.Core.Engine.V2
|
||||
|
@ -10,7 +11,8 @@ namespace Ombi.Core.Engine.V2
|
|||
|
||||
public interface IIssuesEngine
|
||||
{
|
||||
Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status);
|
||||
Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status, CancellationToken token);
|
||||
Task<IEnumerable<IssuesSummaryModel>> GetIssuesByTitle(string title, CancellationToken token);
|
||||
}
|
||||
|
||||
public class IssuesEngine : IIssuesEngine
|
||||
|
@ -28,9 +30,9 @@ namespace Ombi.Core.Engine.V2
|
|||
_comments = comments;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status)
|
||||
public async Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status, CancellationToken token)
|
||||
{
|
||||
var issues = await _issues.GetAll().Where(x => x.Status == status).Skip(position).Take(take).ToListAsync();
|
||||
var issues = await _issues.GetAll().Include(x => x.UserReported).Include(x => x.IssueCategory).Where(x => x.Status == status).Skip(position).Take(take).OrderBy(x => x.Title).ToListAsync(token);
|
||||
var grouped = issues.GroupBy(x => x.Title, (key, g) => new { Title = key, Issues = g });
|
||||
|
||||
var model = new List<IssuesSummaryModel>();
|
||||
|
@ -48,6 +50,27 @@ namespace Ombi.Core.Engine.V2
|
|||
return model;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IssuesSummaryModel>> GetIssuesByTitle(string title, CancellationToken token)
|
||||
{
|
||||
var lowerTitle = title.ToLowerInvariant();
|
||||
var issues = await _issues.GetAll().Include(x => x.UserReported).Include(x => x.IssueCategory).Where(x => x.Title.ToLowerInvariant() == lowerTitle).ToListAsync(token);
|
||||
var grouped = issues.GroupBy(x => x.Title, (key, g) => new { Title = key, Issues = g });
|
||||
|
||||
var model = new List<IssuesSummaryModel>();
|
||||
|
||||
foreach (var group in grouped)
|
||||
{
|
||||
model.Add(new IssuesSummaryModel
|
||||
{
|
||||
Count = group.Issues.Count(),
|
||||
Title = group.Title,
|
||||
Issues = group.Issues
|
||||
});
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class IssuesSummaryModel
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue