diff options
author | Matthew Somerville <matthew@mysociety.org> | 2012-12-12 16:48:27 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2012-12-15 00:11:05 +0000 |
commit | fa4947c017af7599699892c1c3a647fc61f971ed (patch) | |
tree | 71cf677abe1891f40a79fa2a1e606929ad8f7640 /perllib/FixMyStreet/App/Controller/Admin.pm | |
parent | 07b07d90cf666a06cb071ceebcecbd21d91e6b60 (diff) |
Rename area_id on Contacts table to body_id.
Add foreign key constraint from contacts to body.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Admin.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Admin.pm | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Admin.pm b/perllib/FixMyStreet/App/Controller/Admin.pm index fcbde1bd9..8c37f0f2e 100644 --- a/perllib/FixMyStreet/App/Controller/Admin.pm +++ b/perllib/FixMyStreet/App/Controller/Admin.pm @@ -233,15 +233,15 @@ sub council_list : Path('council_list') : Args(0) { my $contacts = $c->model('DB::Contact')->search( undef, { - select => [ 'area_id', { count => 'id' }, { count => \'case when deleted then 1 else null end' }, + select => [ 'body_id', { count => 'id' }, { count => \'case when deleted then 1 else null end' }, { count => \'case when confirmed then 1 else null end' } ], - as => [qw/area_id c deleted confirmed/], - group_by => [ 'area_id' ], + as => [qw/body_id c deleted confirmed/], + group_by => [ 'body_id' ], result_class => 'DBIx::Class::ResultClass::HashRefInflator' } ); - my %council_info = map { $_->{area_id} => $_ } $contacts->all; + my %council_info = map { $_->{body_id} => $_ } $contacts->all; my @no_info = grep { !$council_info{$_} } @councils_ids; my @one_plus_deleted = grep { $council_info{$_} && $council_info{$_}->{deleted} } @councils_ids; @@ -294,7 +294,7 @@ sub update_contacts : Private { my $contact = $c->model('DB::Contact')->find_or_new( { - area_id => $c->stash->{area_id}, + body_id => $c->stash->{area_id}, category => $category, } ); @@ -328,7 +328,7 @@ sub update_contacts : Private { my $contacts = $c->model('DB::Contact')->search( { - area_id => $c->stash->{area_id}, + body_id => $c->stash->{area_id}, category => { -in => \@categories }, } ); @@ -390,7 +390,7 @@ sub display_contacts : Private { my $area_id = $c->stash->{area_id}; my $contacts = $c->model('DB::Contact')->search( - { area_id => $area_id }, + { body_id => $area_id }, { order_by => ['category'] } ); @@ -450,7 +450,7 @@ sub council_edit : Path('council_edit') : Args(2) { my $contact = $c->model('DB::Contact')->search( { - area_id => $area_id, + body_id => $area_id, category => $category } )->first; @@ -459,7 +459,7 @@ sub council_edit : Path('council_edit') : Args(2) { my $history = $c->model('DB::ContactsHistory')->search( { - area_id => $area_id, + body_id => $area_id, category => $category }, { |