Ordo/Command/Sync.pm untested

filter: Statementstmt 0.0% 0 / 45 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 7 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 77 CC 4 SCAR 20.2
CC
4
Cov
0%
execute
20.0
name
2.0
summary
2.0
CRAP 7.5
1 # lib/App/Ordo/Command/Sync.pm
2 package App::Ordo::Command::Sync;
3 use Moo;
4 use feature qw(say);
5 use utf8;
6 use open ':std', ':utf8';
7 extends 'App::Ordo::Command::Base';
8  
9 use Term::ANSIColor qw(colored);
10  
11 sub name { "sync" }
12 sub summary { "Sync scheduler state with remote servers and detect zombie jobs" }
13 sub usage { "" }
14  
15 sub option_spec { {} }
16  
17 sub execute {
18 my ($self) = @_;
19  
20 say colored(["bold yellow"], "Synchronizing with all remote servers...");
21  
22 my $res = $self->api->call('sync', {});
23  
24 unless ($res->{success}) {
25 say colored(["bold red"], "Sync failed: " . ($res->{message} || 'unknown error'));
26 return;
27 }
28  
29 my $msg = $res->{message} || "sync completed";
30 my ($zombies, $revived) = $msg =~ /(\d+) zombies? found.*?(\d+) revived/;
31  
32 if ($zombies && $zombies > 0) {
33 say colored(["bold red"], "$zombies zombie job(s) detected and marked");
34 say colored(["yellow"], "$revived job(s) revived") if $revived;
35 } else {
36 say colored(["bold green"], "All good - no zombies found");
37 }
38  
39 say colored(["bright_black"], $msg);
40 }
41  
42 1;