#!/usr/bin/perl use strict; use warnings; use Carp qw/croak/; use Data::Dumper qw/Dumper/; use Perl6::Say; use Benchmark; use FindBin qw/$Bin/; use lib $Bin . '/..'; use Bulletinboard::Schema; use Config::Auto; my $t0 = Benchmark->new(); my $cfg = Config::Auto::parse($Bin.'/../config/config.pl'); my $schema = Bulletinboard::Schema->connection( $cfg->{db}->{dsn}, $cfg->{db}->{username}, $cfg->{db}->{password}, $cfg->{db}->{attributes}, ); #$schema->storage->debug(1); my @topic_loop = (); my $trs = $schema->resultset('Topic')->search( undef, { order_by => 'me.position ASC', prefetch => [qw/boards/], } ); while( my $topic = $trs->next() ) { say $topic->topic(); my @board_loop = (); foreach my $board ( $topic->boards() ) { say "\t" . $board->title(); # -- get the latest thread my ($lastthread) = $board->threads( undef, { order_by => 'date_of_creation DESC', } )->slice(0,1); print "\t\t" . $lastthread->subject() . ": "; my $lastpost = undef; if( defined $lastthread ) { ($lastpost) = $lastthread->posts( undef, { select => 'timestamp', order_by => 'timestamp DESC', } )->slice(0,1); say $lastpost->timestamp(); }else{ say "no posts"; } } } my $t1 = Benchmark->new(); my $td = Benchmark::timediff($t1, $t0); say 'benchmark_timediff: ' . timestr($td);