From: Bjørn Rustad Date: Tue, 20 Aug 2013 18:42:07 +0000 (+0200) Subject: Fix team import bug X-Git-Url: http://git.rustad.me/?a=commitdiff_plain;h=bc75e5bf7950ed9a8bf90b4a97a76eb6a057c648;p=duplo Fix team import bug --- diff --git a/duplo.sql b/duplo.sql index 4036964..c2c8727 100644 --- a/duplo.sql +++ b/duplo.sql @@ -91,8 +91,7 @@ CREATE TABLE team ( name VARCHAR(64) NOT NULL, cyclingdatabase_id INTEGER, - UNIQUE (name), - UNIQUE (cyclingdatabase_id) + UNIQUE (name) ); GRANT SELECT, UPDATE, INSERT, DELETE ON team TO duplo; diff --git a/lib/Duplo/Results.pm b/lib/Duplo/Results.pm index 12875a1..bcdea22 100644 --- a/lib/Duplo/Results.pm +++ b/lib/Duplo/Results.pm @@ -5,17 +5,6 @@ use Mojo::UserAgent; use Data::Dumper; use Encode qw(decode encode); -sub cdb_getname { - my $id = shift; - - my $ua = Mojo::UserAgent->new; - my $tx = $ua->get("http://cyclingdatabase.com/rider/a/$id"); - - my $name = decode('UTF-8', $tx->res->dom->at('span#rider-name')->text); - - return $name; -} - sub cdb_getlist { my $self = shift; my $url = shift; @@ -47,13 +36,15 @@ sub cdb_getlist { my $team = ''; my $team_id; - if ($tr->td->[3]->can('a')) { + eval { $team = decode('UTF-8', $tr->td->[3]->a->text); $team_id = $tr->td->[3]->a->{'href'} =~ /\/team\/[^\/]*\/(\d+)/; - - } + } or do { + $team = ''; + $team_id = undef; + }; my $name = decode('UTF-8', $tr->td->[2]->a->text); my $time = decode('UTF-8', $tr->td->[4]->text);