Lots of Bugfixes (#2960)

Co-authored-by: Samuel Martins <s@smartins.ch>
Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
Joe Milazzo 2024-05-22 06:58:23 -05:00 committed by GitHub
parent 97ffdd0975
commit b50fa0fd1e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
45 changed files with 563 additions and 282 deletions

View file

@ -60,7 +60,6 @@ public interface IScrobblingService
public class ScrobblingService : IScrobblingService
{
private readonly IUnitOfWork _unitOfWork;
private readonly ITokenService _tokenService;
private readonly IEventHub _eventHub;
private readonly ILogger<ScrobblingService> _logger;
private readonly ILicenseService _licenseService;
@ -99,12 +98,10 @@ public class ScrobblingService : IScrobblingService
private const string AccessTokenErrorMessage = "Access Token needs to be rotated to continue scrobbling";
public ScrobblingService(IUnitOfWork unitOfWork, ITokenService tokenService,
IEventHub eventHub, ILogger<ScrobblingService> logger, ILicenseService licenseService,
ILocalizationService localizationService)
public ScrobblingService(IUnitOfWork unitOfWork, IEventHub eventHub, ILogger<ScrobblingService> logger,
ILicenseService licenseService, ILocalizationService localizationService)
{
_unitOfWork = unitOfWork;
_tokenService = tokenService;
_eventHub = eventHub;
_logger = logger;
_licenseService = licenseService;

View file

@ -142,10 +142,15 @@ public class SmartCollectionSyncService : ISmartCollectionSyncService
// For everything that's not there, link it up for this user.
_logger.LogInformation("Starting Sync on {CollectionName} with {SeriesCount} Series", info.Title, info.TotalItems);
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress,
MessageFactory.SmartCollectionProgressEvent(info.Title, string.Empty, 0, info.TotalItems, ProgressEventType.Started));
var missingCount = 0;
var missingSeries = new StringBuilder();
var counter = -1;
foreach (var seriesInfo in info.Series.OrderBy(s => s.SeriesName))
{
counter++;
try
{
// Normalize series name and localized name
@ -164,7 +169,12 @@ public class SmartCollectionSyncService : ISmartCollectionSyncService
s.NormalizedLocalizedName == normalizedSeriesName)
&& formats.Contains(s.Format));
if (existingSeries != null) continue;
if (existingSeries != null)
{
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress,
MessageFactory.SmartCollectionProgressEvent(info.Title, seriesInfo.SeriesName, counter, info.TotalItems, ProgressEventType.Updated));
continue;
}
// Series not found in the collection, try to find it in the server
var newSeries = await _unitOfWork.SeriesRepository.GetSeriesByAnyName(seriesInfo.SeriesName,
@ -196,6 +206,8 @@ public class SmartCollectionSyncService : ISmartCollectionSyncService
missingSeries.Append("<br/>");
}
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress,
MessageFactory.SmartCollectionProgressEvent(info.Title, seriesInfo.SeriesName, counter, info.TotalItems, ProgressEventType.Updated));
}
// At this point, all series in the info have been checked and added if necessary
@ -213,6 +225,9 @@ public class SmartCollectionSyncService : ISmartCollectionSyncService
await _unitOfWork.CollectionTagRepository.UpdateCollectionAgeRating(collection);
await _eventHub.SendMessageAsync(MessageFactory.NotificationProgress,
MessageFactory.SmartCollectionProgressEvent(info.Title, string.Empty, info.TotalItems, info.TotalItems, ProgressEventType.Ended));
await _eventHub.SendMessageAsync(MessageFactory.CollectionUpdated,
MessageFactory.CollectionUpdatedEvent(collection.Id), false);