aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/DB/Result/User.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/User.pm')
-rw-r--r--perllib/FixMyStreet/DB/Result/User.pm33
1 files changed, 16 insertions, 17 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm
index 997577b69..481b654c9 100644
--- a/perllib/FixMyStreet/DB/Result/User.pm
+++ b/perllib/FixMyStreet/DB/Result/User.pm
@@ -27,7 +27,7 @@ __PACKAGE__->add_columns(
"password",
{ data_type => "text", default_value => "", is_nullable => 0 },
"from_body",
- { data_type => "integer", is_nullable => 1 },
+ { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
"flagged",
{ data_type => "boolean", default_value => \"false", is_nullable => 0 },
"title",
@@ -53,6 +53,17 @@ __PACKAGE__->has_many(
{ "foreign.user_id" => "self.id" },
{ cascade_copy => 0, cascade_delete => 0 },
);
+__PACKAGE__->belongs_to(
+ "from_body",
+ "FixMyStreet::DB::Result::Body",
+ { id => "from_body" },
+ {
+ is_deferrable => 1,
+ join_type => "LEFT",
+ on_delete => "CASCADE",
+ on_update => "CASCADE",
+ },
+);
__PACKAGE__->has_many(
"problems",
"FixMyStreet::DB::Result::Problem",
@@ -61,8 +72,8 @@ __PACKAGE__->has_many(
);
-# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-12 13:06:09
-# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:L6gtjOQeVkebGUIHJcHuUA
+# Created by DBIx::Class::Schema::Loader v0.07017 @ 2012-12-14 09:23:59
+# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:aw374WQraL5ysOvUmUIU3w
__PACKAGE__->add_columns(
"password" => {
@@ -146,20 +157,8 @@ sub alert_for_problem {
sub body {
my $self = shift;
-
return '' unless $self->from_body;
-
- my $key = 'body_name:' . $self->from_body;
- my $result = Memcached::get($key);
-
- ### TODO: Add a 'name' column to body which is used instead of calling mapit
- unless ($result) {
- my $area_info = mySociety::MaPit::call('area', $self->from_body);
- $result = $area_info->{name};
- Memcached::set($key, $result, 86400);
- }
-
- return $result;
+ return $self->from_body->name;
}
=head2 belongs_to_body
@@ -176,7 +175,7 @@ sub belongs_to_body {
my %bodies = map { $_ => 1 } split ',', $bodies;
- return 1 if $self->from_body && $bodies{ $self->from_body };
+ return 1 if $self->from_body && $bodies{ $self->from_body->id };
return 0;
}