# HG changeset patch # User Vincent Tondellier # Date 1431206267 -7200 # Node ID 9e95be0b1b8ca7af0c187f1eae18a2f166004c41 # Parent ca4fa5dc09daca7df19881f0fe1a392b4a2adb76 Make the index columns configurable diff -r ca4fa5dc09da -r 9e95be0b1b8c CrashTest.conf --- a/CrashTest.conf Fri May 08 22:29:20 2015 +0200 +++ b/CrashTest.conf Sat May 09 23:17:47 2015 +0200 @@ -9,7 +9,7 @@ # }, Storage => { Type => "CrashTest::Storage::Sql", - DSN => "dbi:SQLite:dbname=data/db.sqlite", + DSN => "dbi:Pg:dbname=crashreports", DataDir => 'data/', }, DecodeQueue => { @@ -19,7 +19,15 @@ # Type => "CrashTest::Decode::Queue::Gearman", # GearmanServers => [ 'localhost:4730' ], # }, - ScmLinks => { - "svn:svn.example.org/testproject" => 'https://redmine.example.org/projects/testproject/repository/entry/<%= $scmpath =%>?rev=<%= $rev =%>#L<%= $line =%>', + WebInterface => { + ScmLinks => { + "svn:svn.example.org/testproject" => 'https://redmine.example.org/projects/testproject/repository/entry/<%= $scmpath =%>?rev=<%= $rev =%>#L<%= $line =%>', + }, + ExtraColumns => { + Index => [ + { id => 'os', db_column => "crash_user.os", name => 'Operating System' }, + ], + }, }, }; +# vim:ft=perl: diff -r ca4fa5dc09da -r 9e95be0b1b8c CrashTest.pl --- a/CrashTest.pl Fri May 08 22:29:20 2015 +0200 +++ b/CrashTest.pl Sat May 09 23:17:47 2015 +0200 @@ -32,7 +32,10 @@ die ref $e ? "Exception: $e" : 'Not found!'; } - return $storage_class->new(config => $self->app->config->{Storage}); + return $storage_class->new( + config => $self->app->config->{Storage}, + extra_columns => $self->app->config->{WebInterface}->{ExtraColumns}, + ); }); app->attr(decode_queue => sub { @@ -67,6 +70,7 @@ $self->stash(files => $result->{crashs}); $self->stash(pager => $result->{pager}); + $self->stash(extra_columns => $self->app->config->{WebInterface}->{ExtraColumns}->{Index}); $self->render('index'); } => 'index'; diff -r ca4fa5dc09da -r 9e95be0b1b8c lib/CrashTest/StackFilters/FileLink.pm --- a/lib/CrashTest/StackFilters/FileLink.pm Fri May 08 22:29:20 2015 +0200 +++ b/lib/CrashTest/StackFilters/FileLink.pm Sat May 09 23:17:47 2015 +0200 @@ -42,7 +42,7 @@ my $filename = File::Spec->splitpath($scmpath); my $scmrepo = "$scm:$repo"; my $mt = Mojo::Template->new; - my $config = $self->config->{ScmLinks}; + my $config = $self->config->{WebInterface}->{ScmLinks}; # and we have a browser configured for this repository if(exists($config->{$scmrepo})) { diff -r ca4fa5dc09da -r 9e95be0b1b8c lib/CrashTest/Storage/Sql.pm --- a/lib/CrashTest/Storage/Sql.pm Fri May 08 22:29:20 2015 +0200 +++ b/lib/CrashTest/Storage/Sql.pm Sat May 09 23:17:47 2015 +0200 @@ -18,6 +18,8 @@ use CrashTest::Storage::Sql::Schema; use Search::Query; +has [ qw/extra_columns/ ]; + sub new { my $self = shift->SUPER::new(@_); @@ -50,11 +52,25 @@ } } + my @select = (); + my @sel_as = (); + my @extra_ids = (); + + if($self->extra_columns) { + foreach my $extra_col(@{$self->extra_columns->{Index}}) { + push @select, $extra_col->{db_column}; + push @sel_as, $extra_col->{id}; + push @extra_ids, $extra_col->{id}; + } + } + my $dbcrashs = $self->{schema}->resultset('CrashReport')->search_rs( $dbic_query, { - prefetch => [ 'product', 'crash_user' ], - join => 'crash_data', + prefetch => 'product', + join => [ qw/crash_user crash_data/ ], + '+select' => \@select, + '+as' => \@sel_as, order_by => { -desc => 'crash_time' }, page => $page, rows => $nperpage, @@ -65,16 +81,23 @@ pager => $dbcrashs->pager, crashs => [], }; + for my $crash($dbcrashs->all) { my $filename = File::Spec->catfile($self->{data_path}, $crash->uuid); - push @{$results->{crashs}}, { + + my $result = { file => $filename, uuid => $crash->uuid, product => $crash->product->name, version => $crash->product->version, - user => $crash->crash_user->user_id, date => $crash->crash_time, + }; + + foreach (@extra_ids) { + $result->{$_} = $crash->get_column($_); } + + push @{$results->{crashs}}, $result; } return $results; @@ -141,7 +164,6 @@ sub get_processed_data { my ($self, $uuid) = @_; - my $crash = $self->{schema}->resultset('CrashReport')->search( { uuid => $uuid }, { prefetch => 'crash_data' } diff -r ca4fa5dc09da -r 9e95be0b1b8c templates/index.html.ep --- a/templates/index.html.ep Fri May 08 22:29:20 2015 +0200 +++ b/templates/index.html.ep Sat May 09 23:17:47 2015 +0200 @@ -5,8 +5,10 @@ Product Version - UserID UUID + % foreach my $extra_col(@$extra_columns) { + %= t th => $extra_col->{name} + % } Date @@ -14,11 +16,13 @@ %= t tr => begin %= t td => $crash->{product} %= t td => $crash->{version} - %= t td => $crash->{user} %= t td => (style => "font-family:monospace;") => begin %= link_to $crash->{uuid} => url_for('report', uuid => $crash->{uuid}) % end - %= t td => $crash->{date}->strftime("%F %T") + % foreach my $extra_col(@$extra_columns) { + %= t td => $crash->{$extra_col->{id}} + % } + %= t td => $crash->{date}->set_time_zone('UTC')->set_time_zone('local')->strftime("%F %T") % end % } % end