From 8b4f40d0b79736a73704a5bacd8a5d6be50d3f96 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Sat, 23 Jan 2010 20:28:01 +0100 Subject: count perl bytes, some tweaking --- lib/githubexplorer/Repositorie.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'lib/githubexplorer/Repositorie.pm') diff --git a/lib/githubexplorer/Repositorie.pm b/lib/githubexplorer/Repositorie.pm index 907a3b8..6d777b8 100644 --- a/lib/githubexplorer/Repositorie.pm +++ b/lib/githubexplorer/Repositorie.pm @@ -6,9 +6,9 @@ use Net::GitHub::V2::Repositories; sub fetch_repo { my ( $self, $profile, $repo_name ) = @_; - return if $self->_repo_exists($profile, $repo_name); + return if $self->_repo_exists( $profile, $repo_name ); - say "check ".$profile->login."'s $repo_name"; + say "-> check " . $profile->login . "'s $repo_name"; sleep(1); my $github = Net::GitHub::V2::Repositories->new( owner => $profile->login, @@ -16,11 +16,14 @@ sub fetch_repo { login => $self->api_login, token => $self->api_token, ); - my $langs = [ keys %{ $github->languages() } ]; sleep(1); - return unless grep {/perl/i} @$langs; + my $langs = $github->languages(); + sleep(1); + return unless grep {/perl/i} keys %$langs; my $repo_desc = $github->show(); - $repo_desc->{languages} = $langs; + sleep(1); + $profile->perl_total_bytes( $profile->perl_total_bytes + $langs->{Perl} ); + $self->schema->txn_do( sub { $profile->update } ); $self->_create_repo( $profile, $repo_desc ); sleep(1); } @@ -43,8 +46,12 @@ sub _create_repo { map { $_ => $repo_desc->{$_} } (qw/description name homepage url watchers forks/) }; - $repo_rs - = $self->schema->resultset('Repositories')->create($repo_insert); + $self->schema->txn_do( + sub { + $repo_rs = $self->schema->resultset('Repositories') + ->create($repo_insert); + } + ); } $repo_rs; } -- cgit v1.2.3