Skip to content

Commit

Permalink
refactor(Program.cs): move 'PauseAll' method call outside switch stat…
Browse files Browse the repository at this point in the history
…ement to avoid redundancy

fix(Program.cs): remove 'all' case from switch statement as 'PauseAll' is now called by default before the switch
  • Loading branch information
Jossec101 committed Dec 11, 2023
1 parent 112f835 commit cf77a2f
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ async Task ManageJobs(ISchedulerFactory schedulerFactory)
var pauseJobs = Environment.GetEnvironmentVariable("PAUSED_JOBS");
Console.WriteLine($"PAUSED_JOBS env var is {pauseJobs}");
var scheduler = Task.Run(() => schedulerFactory.GetScheduler()).Result;
Console.WriteLine("Pausing all jobs...");
await scheduler.PauseAll();
var triggers = (await scheduler.GetTriggerKeys(GroupMatcher<TriggerKey>.AnyGroup())).ToList();
triggers = triggers.OrderBy(x => x.Name).ToList();

Expand All @@ -75,18 +77,13 @@ async Task ManageJobs(ISchedulerFactory schedulerFactory)

switch (pauseJobs)
{
case "all":
await scheduler.PauseAll();
Console.WriteLine("All jobs paused");
break;


case null:
//Resume all
await scheduler.ResumeAll();
break;
default:
Console.WriteLine("Pausing all jobs...");
await scheduler.PauseAll();


// Get a list of all triggers
foreach (var triggerKey in triggers)
Expand Down

0 comments on commit cf77a2f

Please sign in to comment.