# HG changeset patch # User Vincent Tondellier # Date 1455486149 -3600 # Node ID 4dae01f2beeeaad5adceb6d151a558a883d74dfd # Parent 0e40a68ba421fc3c2b596a97bc598f67a9281431 Allow extra columns in group index, and split search columns diff -r 0e40a68ba421 -r 4dae01f2beee lib/CrashTest/Controller/CrashGroups.pm --- a/lib/CrashTest/Controller/CrashGroups.pm Sun Feb 14 22:39:01 2016 +0100 +++ b/lib/CrashTest/Controller/CrashGroups.pm Sun Feb 14 22:42:29 2016 +0100 @@ -30,7 +30,7 @@ $self->stash(crashs => $results); $self->stash(pager => $pager); - $self->stash(extra_columns => []); + $self->stash(extra_columns => $self->app->config->{WebInterface}->{ExtraColumns}->{GroupIndex}); $self->render("groups/index"); } diff -r 0e40a68ba421 -r 4dae01f2beee lib/CrashTest/Plugin/Storage/Sql/Model/CrashGroup.pm --- a/lib/CrashTest/Plugin/Storage/Sql/Model/CrashGroup.pm Sun Feb 14 22:39:01 2016 +0100 +++ b/lib/CrashTest/Plugin/Storage/Sql/Model/CrashGroup.pm Sun Feb 14 22:42:29 2016 +0100 @@ -38,7 +38,7 @@ my ($self, $search_str) = @_; return $self->sql_utils->build_query_from_search_string( $search_str, - $self->app->config->{WebInterface}->{ExtraColumns}->{Index}, { + $self->app->config->{WebInterface}->{ExtraColumns}->{Search}, { user_id => { name => 'crash_user.user_id' }, product => { name => 'product.name' }, version => { name => 'product.version' }, @@ -72,6 +72,12 @@ $pager->entries_per_page($nperpage); $pager->current_page($pagen); + my @extra_cols; + foreach my $extra_col(@{$self->app->config->{WebInterface}->{ExtraColumns}->{GroupIndex}}) { + push @extra_cols, $extra_col->{db_column} . " AS " . $extra_col->{id}; + } + my $extra_columns = join(",", @extra_cols); + my $results = $self->db->query(" SELECT crash_groups.uuid, title, group_by_count.* FROM crash_groups, @@ -79,7 +85,7 @@ min(version) AS first_version, max(version) AS last_version, string_agg(distinct(name), ', ') AS product_names, - string_agg(distinct(main_module), ', ') AS program_names, + $extra_columns, count(*) AS crash_count FROM crash_reports LEFT JOIN crash_users AS crash_user ON crash_reports.crash_user_id = crash_user.id diff -r 0e40a68ba421 -r 4dae01f2beee lib/CrashTest/Plugin/Storage/Sql/Model/CrashReport.pm --- a/lib/CrashTest/Plugin/Storage/Sql/Model/CrashReport.pm Sun Feb 14 22:39:01 2016 +0100 +++ b/lib/CrashTest/Plugin/Storage/Sql/Model/CrashReport.pm Sun Feb 14 22:42:29 2016 +0100 @@ -42,7 +42,7 @@ my ($self, $search_str) = @_; return $self->sql_utils->build_query_from_search_string( $search_str, - $self->app->config->{WebInterface}->{ExtraColumns}->{Index}, { + $self->app->config->{WebInterface}->{ExtraColumns}->{Search}, { user_id => { name => 'crash_user.user_id' }, product => { name => 'product.name' }, version => { name => 'product.version' }, diff -r 0e40a68ba421 -r 4dae01f2beee templates/groups/index.html.ep --- a/templates/groups/index.html.ep Sun Feb 14 22:39:01 2016 +0100 +++ b/templates/groups/index.html.ep Sun Feb 14 22:42:29 2016 +0100 @@ -8,6 +8,9 @@ First version seen Last version seen Products + % foreach my $extra_col(@$extra_columns) { + %= t th => $extra_col->{name} + % } % foreach my $crash(@$crashs) { @@ -19,6 +22,9 @@ %= t td => $crash->{first_version} %= t td => $crash->{last_version} %= t td => $crash->{product_names} + % foreach my $extra_col(@$extra_columns) { + %= t td => $crash->{$extra_col->{id}} + % } % end % } % end