OPDS Cleanup (#534)
* Fixed opds url display * Rewrote how stat collection works, now we check in multiple places and always run stat collection in a background thread, to not block main thread. * Cleaned up the ParseInfoTest to be more verbose * Added benchmarking
This commit is contained in:
parent
d36c3d62ce
commit
51b9d1a45a
12 changed files with 133 additions and 52 deletions
|
|
@ -2,7 +2,6 @@
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using API.Interfaces;
|
||||
using API.Interfaces.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
|
|
@ -27,7 +26,10 @@ namespace API.Services.HostedServices
|
|||
|
||||
try
|
||||
{
|
||||
await ManageStartupStatsTasks(scope, taskScheduler);
|
||||
// These methods will automatically check if stat collection is disabled to prevent sending any data regardless
|
||||
// of when setting was changed
|
||||
await taskScheduler.ScheduleStatsTasks();
|
||||
taskScheduler.RunStatCollection();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
@ -35,21 +37,6 @@ namespace API.Services.HostedServices
|
|||
}
|
||||
}
|
||||
|
||||
private async Task ManageStartupStatsTasks(IServiceScope serviceScope, ITaskScheduler taskScheduler)
|
||||
{
|
||||
var unitOfWork = serviceScope.ServiceProvider.GetRequiredService<IUnitOfWork>();
|
||||
|
||||
var settingsDto = await unitOfWork.SettingsRepository.GetSettingsDtoAsync();
|
||||
|
||||
if (!settingsDto.AllowStatCollection) return;
|
||||
|
||||
taskScheduler.ScheduleStatsTasks();
|
||||
|
||||
var statsService = serviceScope.ServiceProvider.GetRequiredService<IStatsService>();
|
||||
|
||||
await statsService.CollectAndSendStatsData();
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue