summaryrefslogtreecommitdiff
path: root/lib/GitHub/Collector/Command/repository.pm
blob: 3e7fd57b1f33a0ad63f45c453b0632878748781f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package GitHub::Collector::Command::repository;

use Moose;
use boolean;

extends qw(MooseX::App::Cmd::Command);

with qw(
  GitHub::Collector::Role::Context
  GitHub::Collector::Role::Logger
  GitHub::Collector::Role::SPORE
  GitHub::Collector::Role::MongoDB
  GitHub::Collector::Role::Repository
);

sub execute {
    my $self = shift;

    $self->log("start to crawl repositories");
    $self->_crawl();
    $self->log("crawl completed");
}

sub get_repositories {
    my ($self, $profile) = @_;

    my $login = $profile->{login};

    $self->log("fetch repositories for $login");
    $self->fetch_repositories($profile);
    $self->log("finished to work on $login");
}

sub _crawl {
    my $self = shift;

    my $profiles = $self->db_profiles->find( { repositories_done => false } );

    while ( my $profile = $profiles->next ) {
        $self->get_repositories($profile);
    }
}

1;