From 65ba93acc0a15fd67d1256742831977b6b84a70f Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Thu, 21 Sep 2017 20:05:38 +0100 Subject: [PATCH] #342 Job Queue Add Hostname or FQDN --- lib/App/Netdisco/DB/Result/Admin.pm | 11 +++++++++++ lib/App/Netdisco/JobQueue/PostgreSQL.pm | 1 + share/views/ajax/admintask/jobqueue.tt | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/App/Netdisco/DB/Result/Admin.pm b/lib/App/Netdisco/DB/Result/Admin.pm index cc5daa54..27e0cf9f 100644 --- a/lib/App/Netdisco/DB/Result/Admin.pm +++ b/lib/App/Netdisco/DB/Result/Admin.pm @@ -90,6 +90,17 @@ __PACKAGE__->has_many( device_skips => 'App::Netdisco::DB::Result::DeviceSkip', { cascade_copy => 0, cascade_update => 0, cascade_delete => 0 } ); +=head2 target + +Returns the single C to which this Job entry was associated. + +The JOIN is of type LEFT, in case the C is not in the database. + +=cut + +__PACKAGE__->belongs_to( target => 'App::Netdisco::DB::Result::Device', + { 'foreign.ip' => 'self.device' }, { join_type => 'LEFT' } ); + =head1 METHODS =head2 summary diff --git a/lib/App/Netdisco/JobQueue/PostgreSQL.pm b/lib/App/Netdisco/JobQueue/PostgreSQL.pm index 6de293e1..0f1eda9c 100644 --- a/lib/App/Netdisco/JobQueue/PostgreSQL.pm +++ b/lib/App/Netdisco/JobQueue/PostgreSQL.pm @@ -251,6 +251,7 @@ sub jq_complete { sub jq_log { return schema('netdisco')->resultset('Admin')->search({}, { + prefetch => 'target', order_by => { -desc => [qw/entered device action/] }, rows => 50, })->with_times->hri->all; diff --git a/share/views/ajax/admintask/jobqueue.tt b/share/views/ajax/admintask/jobqueue.tt index b148969d..10ec7df6 100644 --- a/share/views/ajax/admintask/jobqueue.tt +++ b/share/views/ajax/admintask/jobqueue.tt @@ -39,7 +39,7 @@ [% IF row.action == 'discover' AND row.status == 'error' %] [% row.device | html_entity %] [% ELSE %] - [% row.device | html_entity %] + [% row.target.dns || row.device | html_entity %] [% END %] [% row.port | html_entity %]