# HG changeset patch # User Vincent Tondellier # Date 1455488444 -3600 # Node ID 396528bdb9ad03f25246d4323db2f7b36affb1d7 # Parent 8e0a9f88fb470a516147f6c88c431cdad7cf74fa Allow showing a group by the uuid of any of it's individual crash This removes the dependency on insertion order. Also split Group::stats_by_product_and_version from get diff -r 8e0a9f88fb47 -r 396528bdb9ad lib/CrashTest/Controller/CrashGroups.pm --- a/lib/CrashTest/Controller/CrashGroups.pm Sun Feb 14 23:15:36 2016 +0100 +++ b/lib/CrashTest/Controller/CrashGroups.pm Sun Feb 14 23:20:44 2016 +0100 @@ -41,8 +41,8 @@ my $uuid = $self->param('uuid'); my $group = $self->app->crash_groups->get($uuid); - $self->stash(group => $group->{group}); - $self->stash(stats_by_product_and_version => $group->{stats_by_product_and_version}); + $self->stash(group => $self->app->crash_groups->get($uuid)); + $self->stash(stats_by_product_and_version => $self->app->crash_groups->stats_by_product_and_version($uuid)); my $page = 1; my $crashs_per_page = 20; @@ -51,9 +51,9 @@ my $search = $self->req->param('search'); if(defined($search) && $search ne "") { - $search .= " AND " . "group_id=$group->{group}->{id}"; + $search .= " AND " . "group_id=$group->{id}"; } else { - $search = "group_id=$group->{group}->{id}"; + $search = "group_id=$group->{id}"; } my ($results, $pager) = $self->crash_reports->index($page, $crashs_per_page, $search); diff -r 8e0a9f88fb47 -r 396528bdb9ad lib/CrashTest/Model/CrashGroup.pm --- a/lib/CrashTest/Model/CrashGroup.pm Sun Feb 14 23:15:36 2016 +0100 +++ b/lib/CrashTest/Model/CrashGroup.pm Sun Feb 14 23:20:44 2016 +0100 @@ -28,4 +28,10 @@ return $self->app->storage->first("CrashGroup::get", $uuid); } +sub stats_by_product_and_version { + my ($self, $uuid) = @_; + + return $self->app->storage->first("CrashGroup::stats_by_product_and_version", $uuid); +} + 1; diff -r 8e0a9f88fb47 -r 396528bdb9ad lib/CrashTest/Plugin/Storage/Sql/Model/CrashGroup.pm --- a/lib/CrashTest/Plugin/Storage/Sql/Model/CrashGroup.pm Sun Feb 14 23:15:36 2016 +0100 +++ b/lib/CrashTest/Plugin/Storage/Sql/Model/CrashGroup.pm Sun Feb 14 23:20:44 2016 +0100 @@ -108,19 +108,17 @@ my ($self, $uuid) = @_; my $result = $self->db->query(" - SELECT * FROM crash_groups WHERE uuid = ? + SELECT * FROM crash_groups WHERE id = (SELECT crash_group_id FROM crash_reports WHERE uuid = ?) ", $uuid )->hash; - return { - group => $result, - stats_by_product_and_version => $self->_stats_by_product_and_version($result->{id}) - }; + return $result; } -sub _stats_by_product_and_version { - my ($self, $crash_id) = @_; +sub stats_by_product_and_version { + my ($self, $group_uuid) = @_; + my $results = $self->db->query(" SELECT name AS product_name, @@ -128,11 +126,13 @@ count(*) AS crash_count FROM crash_reports JOIN products ON product_id = products.id - WHERE crash_group_id = ? + WHERE crash_group_id = ( + SELECT crash_group_id FROM crash_reports WHERE uuid = ? + ) GROUP BY product_name, version ORDER BY crash_count DESC, product_name, version; ", - $crash_id + $group_uuid )->hashes; return $results; }