Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added mapit IDs for constituencies
  • Loading branch information
davorg committed Nov 28, 2014
1 parent 27f90cd commit 3c6a676
Show file tree
Hide file tree
Showing 3 changed files with 11,748 additions and 2 deletions.
36 changes: 36 additions & 0 deletions bin/get_constit_mapit
@@ -0,0 +1,36 @@
#!/usr/bin/perl -CS

use strict;
use warnings;
use 5.010;

use JSON;
use lib 'lib';
use TwittElection::Schema;

my $file = shift || 'mapit.json';

open my $json_fh, '<', $file or die "$file: $!\n";

my $json = do { local $/; <$json_fh> };
my $data = decode_json($json);

my $sch = TwittElection::Schema->connect(
'dbi:mysql:twittelection',
$ENV{TE_USER}, $ENV{TE_PASS},
) or die;

my $con_rs = $sch->resultset('Constituency');

for (keys $data) {
say "$_ -> $data->{$_}{name}";
my $con = $con_rs->find({ name => $data->{$_}{name} });

unless ($con) {
warn "Can't find $data->{$_}{name}\n";
next;
}

$con->mapit_id($_);
$con->update;
}

0 comments on commit 3c6a676

Please sign in to comment.