diff options
Diffstat (limited to 'perllib/FixMyStreet/DB/Result/User.pm')
-rw-r--r-- | perllib/FixMyStreet/DB/Result/User.pm | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/perllib/FixMyStreet/DB/Result/User.pm b/perllib/FixMyStreet/DB/Result/User.pm index 4ee413a58..ada19a406 100644 --- a/perllib/FixMyStreet/DB/Result/User.pm +++ b/perllib/FixMyStreet/DB/Result/User.pm @@ -26,6 +26,8 @@ __PACKAGE__->add_columns( { data_type => "text", is_nullable => 1 }, "password", { data_type => "text", default_value => "", is_nullable => 0 }, + "from_council", + { data_type => "integer", is_nullable => 1 }, ); __PACKAGE__->set_primary_key("id"); __PACKAGE__->add_unique_constraint("users_email_key", ["email"]); @@ -49,8 +51,8 @@ __PACKAGE__->has_many( ); -# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-23 15:49:48 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:T2JK+KyfoE2hkCLgreq1XQ +# Created by DBIx::Class::Schema::Loader v0.07010 @ 2011-06-27 10:25:21 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9IHuqRTcHZCqJeBAaiQxzw __PACKAGE__->add_columns( "password" => { @@ -132,4 +134,21 @@ sub alert_for_problem { } ); } +sub council { + my $self = shift; + + return '' unless $self->from_council; + + my $key = 'council_name:' . $self->from_council; + my $result = Memcached::get($key); + + unless ($result) { + my $area_info = mySociety::MaPit::call('area', $self->from_council); + $result = $area_info->{name}; + Memcached::set($key, $result, 86400); + } + + return $result; +} + 1; |