diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-01-16 19:29:20 +0100 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-01-16 19:29:20 +0100 |
commit | 1c5ed449f3061d5105f55aca50114199356866f6 (patch) | |
tree | 2302e98ce934258178ddef61b33d70799d847a0e /index.pl | |
parent | 40480626b1f4cf615883f6d285e779bd8dae7dc9 (diff) |
basic output
Diffstat (limited to 'index.pl')
-rw-r--r-- | index.pl | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -1,7 +1,6 @@ #!/usr/bin/env perl use Mojolicious::Lite; -use Data::Dumper; use DateTime; use DBI; use 5.020; @@ -70,9 +69,22 @@ app->attr( dbh => sub { return $dbh } ); get '/' => sub { my ($self) = @_; + my @hostdata; + + my $hostdata_raw = $dbh->selectall_arrayref( + qq{select * from hostdata order by last_contact desc} + ); + my @fields = (qw(hostname contact), @int_fields, @text_fields); + + for my $host (@{$hostdata_raw}) { + push(@hostdata, { + map { ($fields[$_], $host->[$_]) } (0 .. $#fields) + }); + } $self->render( 'main', + hosts => \@hostdata, version => $VERSION, ); }; |