Skip to content

Commit

Permalink
Some Cleanup and Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Jan 6, 2024
1 parent db28cb6 commit e60ea00
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
using Shoko.Server.Commands;
using Shoko.Server.Commands.AniDB;
using Shoko.Server.Extensions;
using Shoko.Server.Filters;
using Shoko.Server.Filters.Legacy;
using Shoko.Server.Models;
using Shoko.Server.Plex;
Expand All @@ -27,7 +26,7 @@
using Shoko.Server.Providers.TraktTV;
using Shoko.Server.Providers.TvDB;
using Shoko.Server.Repositories;
using Shoko.Server.Scheduling.Jobs;
using Shoko.Server.Scheduling.Jobs.Actions;
using Shoko.Server.Server;
using Shoko.Server.Settings;
using Shoko.Server.Utilities;
Expand Down
2 changes: 1 addition & 1 deletion Shoko.Server/API/v2/Modules/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
using Shoko.Server.Filters;
using Shoko.Server.Models;
using Shoko.Server.Repositories;
using Shoko.Server.Scheduling.Jobs;
using Shoko.Server.Scheduling.Jobs.Actions;
using Shoko.Server.Server;
using Shoko.Server.Settings;
using Shoko.Server.Utilities;
Expand Down
3 changes: 1 addition & 2 deletions Shoko.Server/API/v3/Controllers/ActionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
using Shoko.Server.API.v3.Models.Shoko;
using Shoko.Server.Commands;
using Shoko.Server.Commands.AniDB;
using Shoko.Server.Commands.Plex;
using Shoko.Server.Models;
using Shoko.Server.Providers.AniDB;
using Shoko.Server.Providers.AniDB.Interfaces;
using Shoko.Server.Providers.MovieDB;
using Shoko.Server.Providers.TraktTV;
using Shoko.Server.Repositories;
using Shoko.Server.Scheduling.Jobs;
using Shoko.Server.Scheduling.Jobs.Actions;
using Shoko.Server.Server;
using Shoko.Server.Settings;
using Shoko.Server.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@
using QuartzJobFactory.Attributes;
using Shoko.Plugin.Abstractions.Services;

namespace Shoko.Server.Scheduling.Jobs;
namespace Shoko.Server.Scheduling.Jobs.Actions;

[JobKeyMember("UptimeMonitor")]
[JobKeyGroup("System")]
[DisallowConcurrentExecution]
public class ConnectivityMonitorJob : IJob
public class CheckNetworkAvailabilityJob : IJob
{
private readonly IConnectivityService _connectivityService;

public ConnectivityMonitorJob(IConnectivityService connectivityService)
public CheckNetworkAvailabilityJob(IConnectivityService connectivityService)
{
_connectivityService = connectivityService;
}

protected ConnectivityMonitorJob() { }
protected CheckNetworkAvailabilityJob() { }

public async Task Execute(IJobExecutionContext context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Quartz;
using QuartzJobFactory.Attributes;

namespace Shoko.Server.Scheduling.Jobs;
namespace Shoko.Server.Scheduling.Jobs.Actions;

[JobKeyMember("Import")]
[JobKeyGroup("Legacy")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Shoko.Server.Commands;
using Shoko.Server.Repositories;

namespace Shoko.Server.Scheduling.Jobs;
namespace Shoko.Server.Scheduling.Jobs.Actions;

[JobKeyMember("MediaInfo")]
[JobKeyGroup("Legacy")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Quartz;
using QuartzJobFactory.Attributes;

namespace Shoko.Server.Scheduling.Jobs;
namespace Shoko.Server.Scheduling.Jobs.Actions;

[JobKeyMember("RemoveMissingFiles")]
[JobKeyGroup("Legacy")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Quartz;
using QuartzJobFactory.Attributes;

namespace Shoko.Server.Scheduling.Jobs;
namespace Shoko.Server.Scheduling.Jobs.Actions;

[JobKeyMember("ScanDropFolders")]
[JobKeyGroup("Legacy")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Quartz;
using QuartzJobFactory.Attributes;

namespace Shoko.Server.Scheduling.Jobs;
namespace Shoko.Server.Scheduling.Jobs.Shoko;

[JobKeyMember("DeleteImportFolder")]
[JobKeyGroup("Actions")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Quartz;
using QuartzJobFactory.Attributes;

namespace Shoko.Server.Scheduling.Jobs;
namespace Shoko.Server.Scheduling.Jobs.Shoko;

[JobKeyMember("ScanFolder")]
[JobKeyGroup("Actions")]
Expand Down
9 changes: 2 additions & 7 deletions Shoko.Server/Scheduling/QuartzStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Quartz;
using Quartz.AspNetCore;
using QuartzJobFactory;
using Shoko.Server.Scheduling.Jobs;
using Shoko.Server.Scheduling.Jobs.Actions;
using Shoko.Server.Server;
using Shoko.Server.Utilities;

Expand All @@ -19,14 +19,9 @@ internal static void AddQuartz(this IServiceCollection services)
services.AddQuartz(q =>
{
q.UseDatabase();
// as of 3.3.2 this also injects scoped services (like EF DbContext) without problems
q.UseMicrosoftDependencyInjectionJobFactory();

// use the database that we have selected for quartz
//q.UseDatabase();

// Register the connectivity monitor job with a trigger that executes every 5 minutes
q.ScheduleJob<ConnectivityMonitorJob>(
q.ScheduleJob<CheckNetworkAvailabilityJob>(
trigger => trigger.WithSimpleSchedule(tr => tr.WithIntervalInMinutes(5).RepeatForever()).StartNow(),
j => j.DisallowConcurrentExecution().WithGeneratedIdentity());

Expand Down
4 changes: 2 additions & 2 deletions Shoko.Server/Server/ShokoServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using Sentry;
using Shoko.Commons.Properties;
using Shoko.Server.Commands;
using Shoko.Server.Commands.Generic;
using Shoko.Server.Commands.Plex;
using Shoko.Server.Databases;
using Shoko.Server.FileHelper;
Expand All @@ -26,7 +25,8 @@
using Shoko.Server.Providers.JMMAutoUpdates;
using Shoko.Server.Repositories;
using Shoko.Server.Repositories.Cached;
using Shoko.Server.Scheduling.Jobs;
using Shoko.Server.Scheduling.Jobs.Actions;
using Shoko.Server.Scheduling.Jobs.Shoko;
using Shoko.Server.Settings;
using Shoko.Server.Utilities;
using Shoko.Server.Utilities.FileSystemWatcher;
Expand Down
3 changes: 2 additions & 1 deletion Shoko.Server/Server/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
using Shoko.Server.Providers.TraktTV;
using Shoko.Server.Providers.TvDB;
using Shoko.Server.Scheduling;
using Shoko.Server.Scheduling.Jobs;
using Shoko.Server.Scheduling.Jobs.Actions;
using Shoko.Server.Scheduling.Jobs.Shoko;
using Shoko.Server.Services.Connectivity;
using Shoko.Server.Settings;
using Shoko.Server.Utilities;
Expand Down

0 comments on commit e60ea00

Please sign in to comment.