summaryrefslogtreecommitdiff
path: root/lib/githubexplorer
diff options
context:
space:
mode:
Diffstat (limited to 'lib/githubexplorer')
-rw-r--r--lib/githubexplorer/Profile.pm101
1 files changed, 63 insertions, 38 deletions
diff --git a/lib/githubexplorer/Profile.pm b/lib/githubexplorer/Profile.pm
index 94fe040..d9579e4 100644
--- a/lib/githubexplorer/Profile.pm
+++ b/lib/githubexplorer/Profile.pm
@@ -23,6 +23,7 @@ sub fetch_profile {
sleep(1);
if ( !$profile ) {
+ return if $depth > 3;
my $desc = $github->show;
if (!$desc || ($desc && exists $desc->{error})) {
sleep(60);
@@ -35,47 +36,71 @@ sub fetch_profile {
}
}
- my $followers = $github->followers();
- sleep(1);
my $following = $github->following();
- sleep(1);
- my $local_depth = $depth + 1;
-
- unless ( $profile->done ) {
- foreach my $f (@$followers) {
- my $p = $self->fetch_profile( $f, $local_depth );
- next unless $p;
- $self->schema->txn_do(
- sub {
- $self->schema->resultset('Follow')->find_or_create(
- {
- id_following => $profile->id,
- id_follower => $p->id
- }
- );
- }
- );
- }
-
- foreach my $f (@$following) {
- my $p = $self->fetch_profile( $f, $local_depth );
- next unless $p;
- $self->schema->txn_do(
- sub {
- $self->schema->resultset('Follow')->find_or_create(
- {
- id_following => $p->id,
- id_follower => $profile->id
- }
- );
- },
-
- );
+ foreach my $f (@$following) {
+ if (my $p = $self->schema->resultset('Profiles')->find({login => $f})) {
+ $self->schema->txn_do(
+ sub {
+ $self->schema->resultset('Follow')->find_or_create(
+ {
+ id_following => $p->id,
+ id_follower => $profile->id
+ }
+ );
+ },
+
+ );
+ }else{
+ say "need to fetch $f";
}
- $profile->update( { done => 1 } );
+# say "$login follow $f";
+# my $p = $self->fetch_profile( $f, $local_depth );
+# next unless $p;
}
- sleep(1);
- $profile;
+
+# unless ( $profile->done ) {
+# my $followers = $github->followers();
+# sleep(1);
+# my $following = $github->following();
+# sleep(1);
+# my $local_depth = $depth + 1;
+# foreach my $f (@$followers) {
+# say "$login is followed by $f";
+# my $p = $self->fetch_profile( $f, $local_depth );
+# next unless $p;
+# $self->schema->txn_do(
+# sub {
+# $self->schema->resultset('Follow')->find_or_create(
+# {
+# id_following => $profile->id,
+# id_follower => $p->id
+# }
+# );
+# }
+# );
+# }
+#
+# foreach my $f (@$following) {
+# say "$login follow $f";
+# my $p = $self->fetch_profile( $f, $local_depth );
+# next unless $p;
+# $self->schema->txn_do(
+# sub {
+# $self->schema->resultset('Follow')->find_or_create(
+# {
+# id_following => $p->id,
+# id_follower => $profile->id
+# }
+# );
+# },
+#
+# );
+# }
+# say "update profile for $login: done";
+# $profile->update( { done => 1 } );
+# }
+# sleep(1);
+# $profile;
}
sub _profile_exists {