1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-26 22:46:53 -04:00

Fixed: Automation/Integration/Unit Tests

This commit is contained in:
Qstick
2019-09-02 22:22:25 -04:00
parent 944f420270
commit 7f221c7834
123 changed files with 1384 additions and 1191 deletions
@@ -1,22 +1,40 @@
using NzbDrone.Common.EnvironmentInfo;
using System;
using System.Linq;
using NzbDrone.Common.EnvironmentInfo;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.History;
namespace NzbDrone.Core.Analytics
{
public interface IAnalyticsService
{
bool IsEnabled { get; }
bool InstallIsActive { get; }
}
public class AnalyticsService : IAnalyticsService
{
private readonly IConfigFileProvider _configFileProvider;
private readonly IHistoryService _historyService;
public AnalyticsService(IConfigFileProvider configFileProvider)
public AnalyticsService(IHistoryService historyService, IConfigFileProvider configFileProvider)
{
_configFileProvider = configFileProvider;
_historyService = historyService;
}
public bool IsEnabled => _configFileProvider.AnalyticsEnabled;
public bool IsEnabled => _configFileProvider.AnalyticsEnabled && RuntimeInfo.IsProduction || RuntimeInfo.IsDevelopment;
public bool InstallIsActive
{
get
{
var lastRecord = _historyService.Paged(new PagingSpec<History.History>() { Page = 0, PageSize = 1, SortKey = "date", SortDirection = SortDirection.Descending });
var monthAgo = DateTime.UtcNow.AddMonths(-1);
return lastRecord.Records.Any(v => v.Date > monthAgo);
}
}
}
}