projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
659bfc2
)
improve handling of internal errors from US Census geocoding, #39549
author
Mark Wells
<mark@freeside.biz>
Wed, 23 Dec 2015 01:03:07 +0000
(17:03 -0800)
committer
Mark Wells
<mark@freeside.biz>
Wed, 23 Dec 2015 01:22:26 +0000
(17:22 -0800)
FS/FS/Misc/Geo.pm
patch
|
blob
|
history
FS/FS/geocode_Mixin.pm
patch
|
blob
|
history
FS/FS/log.pm
patch
|
blob
|
history
FS/FS/log_context.pm
patch
|
blob
|
history
httemplate/elements/standardize_locations.js
patch
|
blob
|
history
httemplate/search/log.html
patch
|
blob
|
history
diff --git
a/FS/FS/Misc/Geo.pm
b/FS/FS/Misc/Geo.pm
index
168e4e9
..
c02d5dd
100644
(file)
--- a/
FS/FS/Misc/Geo.pm
+++ b/
FS/FS/Misc/Geo.pm
@@
-11,6
+11,7
@@
use JSON;
use URI::Escape 3.31;
use Data::Dumper;
use FS::Conf;
use URI::Escape 3.31;
use Data::Dumper;
use FS::Conf;
+use FS::Log;
use Locale::Country;
FS::UID->install_callback( sub {
use Locale::Country;
FS::UID->install_callback( sub {
@@
-300,6
+301,8
@@
sub standardize_usps {
sub standardize_uscensus {
my $self = shift;
my $location = shift;
sub standardize_uscensus {
my $self = shift;
my $location = shift;
+ my $log = FS::Log->new('FS::Misc::Geo::standardize_uscensus');
+ $log->debug(join("\n", @{$location}{'address1', 'city', 'state', 'zip'}));
eval "use Geo::USCensus::Geocoding";
die $@ if $@;
eval "use Geo::USCensus::Geocoding";
die $@ if $@;
@@
-322,6
+325,7
@@
sub standardize_uscensus {
my $result = Geo::USCensus::Geocoding->query($request);
if ( $result->is_match ) {
# unfortunately we get the address back as a single line
my $result = Geo::USCensus::Geocoding->query($request);
if ( $result->is_match ) {
# unfortunately we get the address back as a single line
+ $log->debug($result->address);
if ($result->address =~ /^(.*), (.*), ([A-Z]{2}), (\d{5}.*)$/) {
return +{
address1 => $1,
if ($result->address =~ /^(.*), (.*), ([A-Z]{2}), (\d{5}.*)$/) {
return +{
address1 => $1,
@@
-341,8
+345,8
@@
sub standardize_uscensus {
} elsif ( $result->match_level ) {
die "Geocoding did not find a matching address.\n";
} else {
} elsif ( $result->match_level ) {
die "Geocoding did not find a matching address.\n";
} else {
-
warn Dumper($result) if $DEBUG
;
- die $result->error_message;
+
$log->error($result->error_message)
;
+ return; # for internal errors, don't return anything
}
}
}
}
diff --git
a/FS/FS/geocode_Mixin.pm
b/FS/FS/geocode_Mixin.pm
index
0625b5a
..
bc8c118
100644
(file)
--- a/
FS/FS/geocode_Mixin.pm
+++ b/
FS/FS/geocode_Mixin.pm
@@
-140,7
+140,7
@@
Returns the full country name.
sub country_full {
my $self = shift;
sub country_full {
my $self = shift;
- $self->code2country($self->
country
);
+ $self->code2country($self->
get('country')
);
}
sub code2country {
}
sub code2country {
diff --git
a/FS/FS/log.pm
b/FS/FS/log.pm
index
a4ad214
..
753a31f
100644
(file)
--- a/
FS/FS/log.pm
+++ b/
FS/FS/log.pm
@@
-114,7
+114,7
@@
sub check {
|| $self->ut_textn('tablename')
|| $self->ut_numbern('tablenum')
|| $self->ut_number('level')
|| $self->ut_textn('tablename')
|| $self->ut_numbern('tablenum')
|| $self->ut_number('level')
- || $self->ut_
text
('message')
+ || $self->ut_
anything
('message')
;
return $error if $error;
;
return $error if $error;
diff --git
a/FS/FS/log_context.pm
b/FS/FS/log_context.pm
index
b2126b8
..
718b4d5
100644
(file)
--- a/
FS/FS/log_context.pm
+++ b/
FS/FS/log_context.pm
@@
-9,6
+9,7
@@
my @contexts = ( qw(
bill_and_collect
FS::cust_main::Billing::bill_and_collect
FS::cust_main::Billing::bill
bill_and_collect
FS::cust_main::Billing::bill_and_collect
FS::cust_main::Billing::bill
+ FS::Misc::Geo::standardize_uscensus
Cron::bill
Cron::upload
spool_upload
Cron::bill
Cron::upload
spool_upload
diff --git
a/httemplate/elements/standardize_locations.js
b/httemplate/elements/standardize_locations.js
index
c285737
..
fed5733
100644
(file)
--- a/
httemplate/elements/standardize_locations.js
+++ b/
httemplate/elements/standardize_locations.js
@@
-114,7
+114,12
@@
function confirm_standardize(arg) {
// then all entered address fields are correct
// but we still need to set the lat/long fields and addr_clean
// then all entered address fields are correct
// but we still need to set the lat/long fields and addr_clean
- status_message('Verified');
+
+ if ( returned['addr_clean'] ) {
+ status_message('Verified');
+ } else {
+ status_message('Unverified');
+ }
replace_address();
} else {
replace_address();
} else {
diff --git
a/httemplate/search/log.html
b/httemplate/search/log.html
index
d1bfb6c
..
7714f46
100644
(file)
--- a/
httemplate/search/log.html
+++ b/
httemplate/search/log.html
@@
-137,7
+137,7
@@
my $tt_sub = sub {
return '' if @context == 1 and length($log->message) <= 60;
my $html = '<DIV CLASS="tooltip">'.(shift @context).'</DIV>';
my $pre = '↳';
return '' if @context == 1 and length($log->message) <= 60;
my $html = '<DIV CLASS="tooltip">'.(shift @context).'</DIV>';
my $pre = '↳';
- foreach (@context, $log->message) {
+ foreach (
map encode_entities($_),
@context, $log->message) {
$html .= "<DIV>$pre$_</DIV>";
$pre = ' '.$pre;
}
$html .= "<DIV>$pre$_</DIV>";
$pre = ' '.$pre;
}