Report Media Issues (#1964)
* Started working on a report problems implementation. * Started code * Added logging to book and archive service. * Removed an additional ComicInfo read when comicinfo is null when trying to load. But we've already done it once earlier, so there really isn't any point. * Added basic implementation for media errors. * MediaErrors will ignore duplicate errors when there are multiple issues on same file in a scan. * Fixed unit tests * Basic code in place to view and clear. Just UI Cleanup needed. * Slight css upgrade * Fixed up centering and simplified the code to use regular array instead of observables as it wasn't working. * Fixed unit tests * Fixed unit tests for real
This commit is contained in:
parent
642b23ed61
commit
d1e4878345
32 changed files with 2586 additions and 57 deletions
83
API/Data/Repositories/MediaErrorRepository.cs
Normal file
83
API/Data/Repositories/MediaErrorRepository.cs
Normal file
|
@ -0,0 +1,83 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.DTOs.MediaErrors;
|
||||
using API.Entities;
|
||||
using API.Helpers;
|
||||
using AutoMapper;
|
||||
using AutoMapper.QueryableExtensions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace API.Data.Repositories;
|
||||
|
||||
public interface IMediaErrorRepository
|
||||
{
|
||||
void Attach(MediaError error);
|
||||
void Remove(MediaError error);
|
||||
Task<MediaError> Find(string filename);
|
||||
Task<PagedList<MediaErrorDto>> GetAllErrorDtosAsync(UserParams userParams);
|
||||
IEnumerable<MediaErrorDto> GetAllErrorDtosAsync();
|
||||
Task<bool> ExistsAsync(MediaError error);
|
||||
Task DeleteAll();
|
||||
}
|
||||
|
||||
public class MediaErrorRepository : IMediaErrorRepository
|
||||
{
|
||||
private readonly DataContext _context;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public MediaErrorRepository(DataContext context, IMapper mapper)
|
||||
{
|
||||
_context = context;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public void Attach(MediaError? error)
|
||||
{
|
||||
if (error == null) return;
|
||||
_context.MediaError.Attach(error);
|
||||
}
|
||||
|
||||
public void Remove(MediaError? error)
|
||||
{
|
||||
if (error == null) return;
|
||||
_context.MediaError.Remove(error);
|
||||
}
|
||||
|
||||
public Task<MediaError?> Find(string filename)
|
||||
{
|
||||
return _context.MediaError.Where(e => e.FilePath == filename).SingleOrDefaultAsync();
|
||||
}
|
||||
|
||||
public Task<PagedList<MediaErrorDto>> GetAllErrorDtosAsync(UserParams userParams)
|
||||
{
|
||||
var query = _context.MediaError
|
||||
.OrderByDescending(m => m.Created)
|
||||
.ProjectTo<MediaErrorDto>(_mapper.ConfigurationProvider)
|
||||
.AsNoTracking();
|
||||
return PagedList<MediaErrorDto>.CreateAsync(query, userParams.PageNumber, userParams.PageSize);
|
||||
}
|
||||
|
||||
public IEnumerable<MediaErrorDto> GetAllErrorDtosAsync()
|
||||
{
|
||||
var query = _context.MediaError
|
||||
.OrderByDescending(m => m.Created)
|
||||
.ProjectTo<MediaErrorDto>(_mapper.ConfigurationProvider)
|
||||
.AsNoTracking();
|
||||
return query.AsEnumerable();
|
||||
}
|
||||
|
||||
public Task<bool> ExistsAsync(MediaError error)
|
||||
{
|
||||
return _context.MediaError.AnyAsync(m => m.FilePath.Equals(error.FilePath)
|
||||
&& m.Comment.Equals(error.Comment)
|
||||
&& m.Details.Equals(error.Details)
|
||||
);
|
||||
}
|
||||
|
||||
public async Task DeleteAll()
|
||||
{
|
||||
_context.MediaError.RemoveRange(await _context.MediaError.ToListAsync());
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue