]> git.rustad.me Git - duplo/commitdiff
Fix team import bug
authorBjørn Rustad <rustadbjornen@gmail.com>
Tue, 20 Aug 2013 18:42:07 +0000 (20:42 +0200)
committerBjørn Rustad <rustadbjornen@gmail.com>
Tue, 20 Aug 2013 18:42:07 +0000 (20:42 +0200)
duplo.sql
lib/Duplo/Results.pm

index 40369648ce7eb3b35b2f2e10049392591ca2e34a..c2c872761a4f9136c9347fb6c4f7bb0ba67ff48f 100644 (file)
--- 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;
index 12875a1977fe7f34954545dd1ad6e3992067b969..bcdea227bf94629e4c2ec8e1822142e65b18d536 100644 (file)
@@ -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);