[NUUG fiksgatami] send-alert cron job complain with "No Area matches the given query." (Was: Service announced, and strange error from the send-alert cron job)

Petter Reinholdtsen pere at hungry.com
Fri Apr 8 14:27:09 CEST 2011


[Petter Reinholdtsen]
> The send-alert cron job started tonight to report "No Area matches
> the given query.".  Anyone got any idea why and if something is
> wrong?

This error every hour is still going on, and I finally found time to
try to debug it.

I applied this patch and ran the script.

diff --git a/perllib/FixMyStreet/Alert.pm b/perllib/FixMyStreet/Alert.pm
index cfe9c17..7ed4a61 100644
--- a/perllib/FixMyStreet/Alert.pm
+++ b/perllib/FixMyStreet/Alert.pm
@@ -35,6 +35,7 @@ use mySociety::MaPit;
 use mySociety::Random qw(random_bytes);
 use mySociety::Sundries qw(ordinal);
 use mySociety::Web qw(ent);
+use Data::Dumper;

 # Add a new alert
 sub create ($$$$;@) {
@@ -158,7 +159,9 @@ sub email_alerts ($) {
             if (!$data{alert_email}) {
                 %data = (%data, %$row);
                 if ($ref eq 'area_problems' || $ref eq 'council_problems' || $ref eq 'ward_problems') {
+print STDERR "Looking up voting area\n", Dumper($row),"\n";
                     my $va_info = mySociety::MaPit::get_voting_area_info($row->{alert_parameter});
+print STDERR "Finished looking up voting area\n";
                     $data{area_name} = $va_info->{name};
                 }
                 if ($ref eq 'ward_problems') {
@@ -263,7 +266,7 @@ sub generate_rss ($$$;$$$$) {
         . ($alert_type->{head_table} ? $alert_type->{head_table}.'_id=? and ' : '')
         . $alert_type->{item_where} . $site_restriction . ' order by '
         . $alert_type->{item_order};
-    $query .= ' limit 20' unless $type =~ /^all/;
+    $query .= ' limit 200' unless $type =~ /^all/;
     $q = dbh()->prepare($query);
     if ($query =~ /\?/) {
         throw FixMyStreet::Alert::Error('Missing parameter') unless @$db_params;

The output from the script is this:

# run-with-lockfile -n /srv/fiksgatami-prod.nuug.no/send-alerts.lock /srv/fiksgatami-prod.nuug.no/fixmystreet/bin/send-alerts
Looking up voting area
$VAR1 = {
          'send_questionnaire' => 1,
          'photo' => undef,
          'item_id' => 3359,
          'state' => 'confirmed',
          'lastupdate' => '2011-04-02 11:15:02.573429',
          'email' => 'XXX at XXX.no',
          'alert_email' => 'fiksgatami.no at XXX.XX',
          'confirmed' => '2011-04-02 11:10:31.387496',
          'latitude' => '60.619265',
          'whensent' => '2011-04-02 11:15:02.573429',
          'category' => 'Annet',
          'alert_parameter' => '12',
          'id' => 3359,
          'alert_lang' => 'nb',
          'cobrand' => 'fiksgatami',
          'longitude' => '5.583295',
          'lang' => 'nb',
          'name' => "\x{d8}ystein Lone",
          'anonymous' => 1,
          'service' => '',
          'cobrand_data' => '',
          'alert_parameter2' => undef,
          'title' => "D\x{e5}rlig vei",
          'areas' => ',12,1253,',
          'alert_cobrand_data' => '',
          'council' => '1253,12',
          'used_map' => 1,
          'postcode' => '5284',
          'phone' => '',
          'alert_cobrand' => 'fiksgatami',
          'detail' => 'Ein forferdelig dump i veien',
          'created' => '2011-04-02 11:09:44.889237',
          'alert_id' => 18
        };

No Area matches the given query.#

As far as I can tell, the script crashes when this message show up,
and thus some alerts might not be processed.

Would very much welcome ideas on how to proceed with the debugging.

PS: I masked the mail address to make it harder for harvesters reading
the mailing list archive.

Happy hacking
-- 
Petter Reinholdtsen


More information about the fiksgatami mailing list