diff options
author | franck cuny <franck@lumberjaph.net> | 2010-02-10 11:07:46 +0100 |
---|---|---|
committer | franck cuny <franck@lumberjaph.net> | 2010-02-10 11:07:46 +0100 |
commit | 3db726a7164632f3f6814f463c46cc5493164270 (patch) | |
tree | 85f73270ae2c54908955351deb6cd957c2d3bd8d /lib/githubexplorer/Network.pm | |
parent | update to create graph (diff) | |
download | github-explorer-3db726a7164632f3f6814f463c46cc5493164270.tar.gz |
update to create graph
Diffstat (limited to 'lib/githubexplorer/Network.pm')
-rw-r--r-- | lib/githubexplorer/Network.pm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/githubexplorer/Network.pm b/lib/githubexplorer/Network.pm new file mode 100644 index 0000000..e3c4765 --- /dev/null +++ b/lib/githubexplorer/Network.pm @@ -0,0 +1,34 @@ +package githubexplorer::Network; +use 5.010; +use Moose::Role; +use Net::GitHub::V2::Repositories; +use YAML::Syck; + +sub fetch_network { + my ( $self, $repos ) = @_; + + my $api_repos = Net::GitHub::V2::Repositories->new( + owner => $repos->id_profile->login, + repo => $repos->name, + login => $self->api_login, + token => $self->api_token, + ); + + my $edges = $api_repos->network(); + foreach my $edge (@$network) { + next if $edge->{owner} eq $repos->id_profile->login; + my $profile = $self->schema->resultset('Profiles') + ->find( { login => $edge->{owner} } ); + next if !$profile; + + my $relation = $self->schema->resultset('Fork')->find_or_create( + { + profile => $profile->id, + repos => $repos->id + } + ); + } + sleep(1); +} + +1; |