__PACKAGE__->table(
"admin"
);
__PACKAGE__->add_columns(
"job"
,
{
data_type
=>
"integer"
,
is_auto_increment
=> 1,
is_nullable
=> 0,
sequence
=>
"admin_job_seq"
,
},
"entered"
,
{
data_type
=>
"timestamp"
,
default_value
=> \
"LOCALTIMESTAMP"
,
is_nullable
=> 1,
original
=> {
default_value
=> \
"LOCALTIMESTAMP"
},
},
"started"
,
{
data_type
=>
"timestamp"
,
is_nullable
=> 1 },
"finished"
,
{
data_type
=>
"timestamp"
,
is_nullable
=> 1 },
"device"
,
{
data_type
=>
"inet"
,
is_nullable
=> 1 },
"port"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
"action"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
"subaction"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
"status"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
"username"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
"userip"
,
{
data_type
=>
"inet"
,
is_nullable
=> 1 },
"log"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
"debug"
,
{
data_type
=>
"boolean"
,
is_nullable
=> 1 },
"device_key"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
"backend"
,
{
data_type
=>
"text"
,
is_nullable
=> 1 },
);
__PACKAGE__->set_primary_key(
"job"
);
__PACKAGE__->might_have(
device_skips
=>
'App::Netdisco::DB::Result::DeviceSkip'
,
sub
{
my
$args
=
shift
;
return
{
"$args->{foreign_alias}.backend"
=> {
'='
=> \
'?'
},
"$args->{foreign_alias}.device"
=> {
-ident
=>
"$args->{self_alias}.device"
},
-or
=> [
"$args->{foreign_alias}.actionset"
=> {
'@>'
=> \
"string_to_array($args->{self_alias}.action,'')"
},
-and
=> [
"$args->{foreign_alias}.deferrals"
=> {
'>='
=> \
'?'
},
"$args->{foreign_alias}.last_defer"
=>
{
'>'
, \
'(LOCALTIMESTAMP - ?::interval)'
},
],
],
};
},
{
cascade_copy
=> 0,
cascade_update
=> 0,
cascade_delete
=> 0 }
);
__PACKAGE__->belongs_to(
target
=>
'App::Netdisco::DB::Result::Device'
,
{
'foreign.ip'
=>
'self.device'
}, {
join_type
=>
'LEFT'
} );
sub
display_name {
my
$job
=
shift
;
return
join
' '
,
$job
->action,
(
$job
->device ||
''
),
(
$job
->port ||
''
);
}
sub
entered_stamp {
return
(
shift
)->get_column(
'entered_stamp'
) }
sub
started_stamp {
return
(
shift
)->get_column(
'started_stamp'
) }
sub
finished_stamp {
return
(
shift
)->get_column(
'finished_stamp'
) }
sub
duration {
return
(
shift
)->get_column(
'duration'
) }
1;