1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Removed DM - Branched if required later.

This commit is contained in:
Mark McDowall 2012-08-13 17:05:01 -07:00
parent 4c85c8761f
commit 653a0864c3
10 changed files with 1 additions and 291 deletions

View File

@ -49,9 +49,6 @@ public static bool IsDebug
public static Guid UGuid { get; set; }
public static bool RegisterNewInstall { get; set; }
public virtual bool IsUserInteractive
{
get { return Environment.UserInteractive; }
@ -102,7 +99,6 @@ private static bool IsRoot(DirectoryInfo dir)
return dir.GetDirectories(ROOT_MARKER).Length != 0;
}
public virtual string StartUpPath
{
get

View File

@ -101,13 +101,5 @@ public void JobProvider_should_be_singletone()
first.Should().BeSameAs(second);
}
[Test]
public void app_should_be_marked_as_new_install_if_db_is_initilized_for_the_first_time()
{
WithRealDb();
EnvironmentProvider.RegisterNewInstall.Should().Be(true);
}
}
}
}

View File

@ -111,7 +111,6 @@
<Compile Include="JobTests\BacklogSearchJobTest.cs" />
<Compile Include="JobTests\BannerDownloadJobTest.cs" />
<Compile Include="JobTests\RecentBacklogSearchJobTest.cs" />
<Compile Include="ProviderTests\AnalyticsProviderTests\AnalyticsProviderFixture.cs" />
<Compile Include="ProviderTests\ConfigProviderTests\ConfigCachingFixture.cs" />
<Compile Include="ProviderTests\BannerProviderTest.cs" />
<Compile Include="ProviderTests\Metadata\Xbmc_ForEpisodeFile_Fixture.cs" />

View File

@ -1,146 +0,0 @@
using System;
using System.Linq;
using DeskMetrics;
using Moq;
using NUnit.Framework;
using NzbDrone.Common;
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Test.Framework;
namespace NzbDrone.Core.Test.ProviderTests.AnalyticsProviderTests
{
// ReSharper disable InconsistentNaming
public class AnalyticsProviderFixture : CoreTest
{
[SetUp]
public void Setup()
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns(UpdateProvider.DEFAULT_UPDATE_URL);
}
private void WithStageClient()
{
Mocker.SetConstant(new DeskMetricsClient(Guid.NewGuid().ToString(), AnalyticsProvider.DESKMETRICS_TEST_ID, new Version(9, 9, 9)));
}
[Test]
public void checkpoint_should_stop_existing_start_then_start_again()
{
Mocker.GetMock<IDeskMetricsClient>().SetupGet(c => c.Started).Returns(true);
var provider = Mocker.Resolve<AnalyticsProvider>();
provider.Checkpoint();
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.Start(), Times.Once());
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.Stop(), Times.Once());
}
[Test]
public void checkpoint_should_not_stop_existing_if_not_started()
{
Mocker.GetMock<IDeskMetricsClient>().SetupGet(c => c.Started).Returns(false);
var provider = Mocker.Resolve<AnalyticsProvider>();
provider.Checkpoint();
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.Start(), Times.Once());
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.Stop(), Times.Never());
}
[Test]
public void new_install_should_be_registered()
{
EnvironmentProvider.RegisterNewInstall = true;
var provider = Mocker.Resolve<AnalyticsProvider>();
provider.Checkpoint();
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.RegisterInstall(), Times.Once());
}
[Test]
public void new_install_should_only_be_registered_on_first_call()
{
EnvironmentProvider.RegisterNewInstall = true;
var provider = Mocker.Resolve<AnalyticsProvider>();
provider.Checkpoint();
provider.Checkpoint();
provider.Checkpoint();
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.RegisterInstall(), Times.Once());
}
[Test]
public void upgrade_should_not_register_install()
{
EnvironmentProvider.RegisterNewInstall = false;
var provider = Mocker.Resolve<AnalyticsProvider>();
provider.Checkpoint();
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.RegisterInstall(), Times.Never());
}
[Test]
public void shouldnt_register_anything_if_not_on_master_branch()
{
EnvironmentProvider.RegisterNewInstall = false;
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
Mocker.GetMock<IDeskMetricsClient>(MockBehavior.Strict);
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
}
[Test]
public void new_install_shouldnt_register_anything_if_not_on_master_branch()
{
EnvironmentProvider.RegisterNewInstall = true;
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns("http://update.nzbdrone.com/master_auto/");
Mocker.GetMock<IDeskMetricsClient>(MockBehavior.Strict);
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
}
[Test]
public void should_be_able_to_call_deskmetrics_using_test_appid()
{
EnvironmentProvider.RegisterNewInstall = true;
Mocker.Resolve<AnalyticsProvider>().Checkpoint();
}
[TestCase("http://update.nzbdrone.com/master/")]
[TestCase("http://update.nzbdrone.com/master//")]
[TestCase("http://update.nzbdrone.com/master")]
[TestCase("http://update.nzbdrone.com/master ")]
[TestCase("http://update.nzbdrone.com/master/ ")]
[TestCase("http://UPDATE.nzbdrone.COM/master/ ")]
public void should_still_work_if_url_is_slightly_diffrent(string url)
{
Mocker.GetMock<ConfigProvider>().SetupGet(c => c.UpdateUrl).Returns(url);
var provider = Mocker.Resolve<AnalyticsProvider>();
provider.Checkpoint();
Mocker.GetMock<IDeskMetricsClient>().Verify(c => c.Start(), Times.Once());
}
}
}

View File

@ -74,16 +74,6 @@ private void InitReporting()
EnvironmentProvider.UGuid = Kernel.Get<ConfigProvider>().UGuid;
ReportingService.RestProvider = Kernel.Get<RestProvider>();
ReportingService.SetupExceptronDriver();
var appId = AnalyticsProvider.DESKMETRICS_TEST_ID;
if (EnvironmentProvider.IsProduction)
appId = AnalyticsProvider.DESKMETRICS_PRODUCTION_ID;
var deskMetricsClient = new DeskMetricsClient(Kernel.Get<ConfigProvider>().UGuid.ToString(), appId, _environmentProvider.Version);
Kernel.Bind<IDeskMetricsClient>().ToConstant(deskMetricsClient);
Kernel.Get<AnalyticsProvider>().Checkpoint();
}
private void InitQuality()
@ -142,7 +132,6 @@ private void InitJobs()
Kernel.Bind<IJob>().To<AppUpdateJob>().InSingletonScope();
Kernel.Bind<IJob>().To<TrimLogsJob>().InSingletonScope();
Kernel.Bind<IJob>().To<RecentBacklogSearchJob>().InSingletonScope();
Kernel.Bind<IJob>().To<CheckpointJob>().InSingletonScope();
Kernel.Bind<IJob>().To<SearchHistoryCleanupJob>().InSingletonScope();
Kernel.Bind<IJob>().To<PastWeekBacklogSearchJob>().InSingletonScope();
Kernel.Bind<IJob>().To<RefreshEpisodeMetadata>().InSingletonScope();

View File

@ -11,9 +11,6 @@ public class Migration20110707 : NzbDroneMigration
{
protected override void MainDbUpgrade()
{
//This should not run unless for a clean install
EnvironmentProvider.RegisterNewInstall = true;
Database.AddTable("Series", new[]
{
new Column("SeriesId", DbType.Int32, ColumnProperty.PrimaryKey),

View File

@ -1,40 +0,0 @@
using System;
using System.Linq;
using Ninject;
using NzbDrone.Common;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers;
namespace NzbDrone.Core.Jobs
{
public class CheckpointJob : IJob
{
private readonly AnalyticsProvider _analyticsProvider;
[Inject]
public CheckpointJob(AnalyticsProvider analyticsProvider)
{
_analyticsProvider = analyticsProvider;
}
public CheckpointJob()
{
}
public string Name
{
get { return "Checkpoint Job"; }
}
public TimeSpan DefaultInterval
{
get { return TimeSpan.FromDays(1); }
}
public void Start(ProgressNotification notification, int targetId, int secondaryTargetId)
{
_analyticsProvider.Checkpoint();
}
}
}

View File

@ -252,7 +252,6 @@
<Compile Include="Helpers\EpisodeSortingHelper.cs" />
<Compile Include="Helpers\SortHelper.cs" />
<Compile Include="Helpers\SabnzbdPriorityTypeConverter.cs" />
<Compile Include="Jobs\CheckpointJob.cs" />
<Compile Include="Jobs\RefreshEpsiodeMetadata.cs" />
<Compile Include="Jobs\PastWeekBacklogSearchJob.cs" />
<Compile Include="Jobs\SearchHistoryCleanupJob.cs" />
@ -320,9 +319,6 @@
<Compile Include="Jobs\IJob.cs" />
<Compile Include="Jobs\RssSyncJob.cs" />
<Compile Include="Jobs\UpdateInfoJob.cs" />
<Compile Include="Providers\AnalyticsProvider.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Providers\StatsProvider.cs" />
<Compile Include="Repository\MetadataDefinition.cs" />
<Compile Include="Repository\Search\SearchHistoryItem.cs" />

View File

@ -1,71 +0,0 @@
using System;
using System.Linq;
using DeskMetrics;
using NLog;
using Ninject;
using NzbDrone.Common;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{
public class AnalyticsProvider
{
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
private readonly IDeskMetricsClient _deskMetricsClient;
private readonly ConfigProvider _configProvider;
public const string DESKMETRICS_TEST_ID = "4ea8d347a14ad71442000002";
public const string DESKMETRICS_PRODUCTION_ID = "4f20b01ea14ad729b2000000";
[Inject]
public AnalyticsProvider(IDeskMetricsClient deskMetricsClient, ConfigProvider configProvider)
{
_deskMetricsClient = deskMetricsClient;
_configProvider = configProvider;
}
public AnalyticsProvider()
{
}
public virtual void Checkpoint()
{
try
{
//Don't report anything unless working from master branch.
if (!IsOnMasterBranch())
return;
if (EnvironmentProvider.RegisterNewInstall)
{
_deskMetricsClient.RegisterInstall();
EnvironmentProvider.RegisterNewInstall = false;
}
if (_deskMetricsClient.Started)
{
_deskMetricsClient.Stop();
}
_deskMetricsClient.Start();
}
catch (Exception e)
{
if (!EnvironmentProvider.IsProduction)
throw;
logger.WarnException("Error while sending analytics data.", e);
}
}
private bool IsOnMasterBranch()
{
var defaultUpdateUrl = UpdateProvider.DEFAULT_UPDATE_URL.Trim().Trim('/');
var currentUpdateUrl = _configProvider.UpdateUrl.Trim().Trim('/');
return String.Equals(defaultUpdateUrl, currentUpdateUrl, StringComparison.InvariantCultureIgnoreCase);
}
}
}

View File

@ -45,8 +45,6 @@ protected string VirtualPath
[SetUp]
public void TestBaseSetup()
{
EnvironmentProvider.RegisterNewInstall = true;
MockedRestProvider = new Mock<RestProvider>();
ReportingService.RestProvider = MockedRestProvider.Object;
ReportingService.SetupExceptronDriver();