Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' into release

  • Loading branch information...
commit ae9601edcb1b14a656fc9e5bf0351fa080c43967 2 parents 00ac2d8 + aed6f54
Dave Cross authored July 31, 2013
9  PoliticalWeb/lib/PoliticalWeb/Constituency.pm
@@ -40,7 +40,7 @@ sub name_from_postcode {
40 40
     my $constit = from_json(encode('utf8', decode('iso-8859-1', $ret->{results})));
41 41
     # debug Dumper $constit;
42 42
     return if $constit->{error};
43  
-    cache_set 'C:' . $constit->{name}, $constit, 60*60*60;
  43
+    # cache_set 'C:' . $constit->{name}, $constit, 60*60*60;
44 44
     return $constit->{name};
45 45
   }
46 46
   
@@ -64,7 +64,9 @@ sub new_from_name {
64 64
 }
65 65
 
66 66
 sub _get_from_cache {
67  
-  return cache_get "C:$_[0]";
  67
+  my $name = shift;
  68
+  $name =~ s/\s+/+/g;
  69
+  return cache_get "C:$name";
68 70
 }
69 71
 
70 72
 sub _get_from_twfy {
@@ -80,7 +82,8 @@ sub _get_from_twfy {
80 82
   if ($ret->{is_success}) {
81 83
     my $con = from_json(encode('utf8', $ret->{results}));
82 84
     return if $con->{error};
83  
-    # debug "Setting cache key - 'C:$_[0]'";
  85
+    $name =~ s/\s+/+/g;
  86
+    debug "Setting cache key - 'C:$name'";
84 87
     # debug 'Setting cache val - ' . Dumper(from_json(encode('utf8', $ret->{results})));
85 88
     cache_set "C:$name", $con, 60*60*60;
86 89
   } else {
5  PoliticalWeb/lib/PoliticalWeb/Mp.pm
@@ -39,7 +39,9 @@ sub new_from_constituency_name {
39 39
 }
40 40
 
41 41
 sub _get_from_cache {
42  
-  return cache_get "M:$_[0]";  
  42
+  my $name = shift;
  43
+  $name =~ s/\s+/+/g;
  44
+  return cache_get "M:$name";  
43 45
 }
44 46
 
45 47
 sub _get_from_twfy {
@@ -66,6 +68,7 @@ sub _get_from_twfy {
66 68
       $mp->{extra} = from_json(encode('utf8', decode('iso-8859-1', $ret->{results})));   
67 69
     }
68 70
 
  71
+    $constit_name =~ s/\s+/+/g;
69 72
     cache_set "M:$constit_name", $mp, 60*60*60;
70 73
   } else {
71 74
     return;

0 notes on commit ae9601e

Please sign in to comment.
Something went wrong with that request. Please try again.