mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-20 13:23:20 -07:00
more wip on the issues
This commit is contained in:
parent
1289b840a0
commit
6683f8070c
19 changed files with 209 additions and 151 deletions
|
@ -12,7 +12,7 @@ namespace Ombi.Core.Engine.V2
|
|||
public interface IIssuesEngine
|
||||
{
|
||||
Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status, CancellationToken token);
|
||||
Task<IEnumerable<IssuesSummaryModel>> GetIssuesByTitle(string title, CancellationToken token);
|
||||
Task<IssuesSummaryModel> GetIssuesByProviderId(string providerId, CancellationToken token);
|
||||
}
|
||||
|
||||
public class IssuesEngine : IIssuesEngine
|
||||
|
@ -32,7 +32,7 @@ namespace Ombi.Core.Engine.V2
|
|||
|
||||
public async Task<IEnumerable<IssuesSummaryModel>> GetIssues(int position, int take, IssueStatus status, CancellationToken token)
|
||||
{
|
||||
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 issues = await _issues.GetAll().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>();
|
||||
|
@ -43,32 +43,30 @@ namespace Ombi.Core.Engine.V2
|
|||
{
|
||||
Count = group.Issues.Count(),
|
||||
Title = group.Title,
|
||||
Issues = group.Issues
|
||||
ProviderId = group.Issues.FirstOrDefault()?.ProviderId
|
||||
});
|
||||
}
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<IssuesSummaryModel>> GetIssuesByTitle(string title, CancellationToken token)
|
||||
public async Task<IssuesSummaryModel> GetIssuesByProviderId(string providerId, 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 issues = await _issues.GetAll().Include(x => x.Comments).ThenInclude(x => x.User).Include(x => x.UserReported).Include(x => x.IssueCategory).Where(x => x.ProviderId == providerId).ToListAsync(token);
|
||||
var grouped = issues.GroupBy(x => x.Title, (key, g) => new { Title = key, Issues = g }).FirstOrDefault();
|
||||
|
||||
var model = new List<IssuesSummaryModel>();
|
||||
|
||||
foreach (var group in grouped)
|
||||
if (grouped == null)
|
||||
{
|
||||
model.Add(new IssuesSummaryModel
|
||||
{
|
||||
Count = group.Issues.Count(),
|
||||
Title = group.Title,
|
||||
Issues = group.Issues
|
||||
});
|
||||
return null;
|
||||
}
|
||||
|
||||
return model;
|
||||
return new IssuesSummaryModel
|
||||
{
|
||||
Count = grouped.Issues.Count(),
|
||||
Title = grouped.Title,
|
||||
ProviderId = grouped.Issues.FirstOrDefault()?.ProviderId,
|
||||
Issues = grouped.Issues
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -77,6 +75,7 @@ namespace Ombi.Core.Engine.V2
|
|||
{
|
||||
public string Title { get; set; }
|
||||
public int Count { get; set; }
|
||||
public string ProviderId { get; set; }
|
||||
public IEnumerable<Issues> Issues { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue