From 2032330372c4c6768c2a93dfea37c9965cca484f Mon Sep 17 00:00:00 2001 From: Dave Cross Date: Thu, 15 Jan 2015 20:01:42 +0000 Subject: [PATCH] Cleaned up output. --- bin/get_cands | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/bin/get_cands b/bin/get_cands index ad9824e9f6..1dbab709ea 100755 --- a/bin/get_cands +++ b/bin/get_cands @@ -57,9 +57,6 @@ foreach my $con ($cons_rs->all) { for (values %cands) { my $cand = $_->{person_id}{versions}[0]{data}; - say $cand->{name}, ' / ', $cand->{party_memberships}{2015}{name}, - ' / @', $cand->{twitter_username}; - my ($party_id) = $cand->{party_memberships}{2015}{id} =~ /(\d+)/; my $party; unless ($party = $par_rs->find({ yournextmp_id => $party_id })) { @@ -72,17 +69,27 @@ foreach my $con ($cons_rs->all) { if (exists $curr_cands{$cand->{id}}) { my $curr_cand = delete $curr_cands{$cand->{id}}; if ($cand->{name} ne $curr_cand->name - or $cand->{twitter_username} ne $curr_cand->twitter) { - $curr_cand->update({ - yournextmp_id => $cand->{id}, - name => $cand->{name}, - twitter => $cand->{twitter_username}, - party_id => $party->id, - constituency_id => $con->id, - }); - $changed = 1; + or $cand->{twitter_username} ne $curr_cand->twitter) { + say "* Updating $cand->{name} / ", + $cand->{party_memberships}{2015}{name}, + " / \@$cand->{twitter_username}"; + $curr_cand->update({ + yournextmp_id => $cand->{id}, + name => $cand->{name}, + twitter => $cand->{twitter_username}, + party_id => $party->id, + constituency_id => $con->id, + }); + $changed = 1; + } else { + say "* No change $cand->{name} / ", + $cand->{party_memberships}{2015}{name}, + " / \@$cand->{twitter_username}"; } } else { + say "* Adding $cand->{name} / ", + $cand->{party_memberships}{2015}{name}, + " / \@$cand->{twitter_username}"; $can_rs->create({ yournextmp_id => $cand->{id}, name => $cand->{name},