summaryrefslogtreecommitdiff
path: root/lib/GitHub/Collector/Command/indegree.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2011-06-13 16:33:23 +0200
committerfranck cuny <franck@lumberjaph.net>2011-06-13 16:33:23 +0200
commit871336c030209b46ae6b124a702677363487f9a8 (patch)
tree86f234d42c68b26a7aeb9cc373667127ad661e19 /lib/GitHub/Collector/Command/indegree.pm
parentuse template_toolkit and add infos about colors (diff)
downloadstargit-871336c030209b46ae6b124a702677363487f9a8.tar.gz
import github::collector
Signed-off-by: franck cuny <franck@lumberjaph.net>
Diffstat (limited to 'lib/GitHub/Collector/Command/indegree.pm')
-rw-r--r--lib/GitHub/Collector/Command/indegree.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/GitHub/Collector/Command/indegree.pm b/lib/GitHub/Collector/Command/indegree.pm
new file mode 100644
index 0000000..fe9bf78
--- /dev/null
+++ b/lib/GitHub/Collector/Command/indegree.pm
@@ -0,0 +1,29 @@
+package GitHub::Collector::Command::indegree;
+
+use Moose;
+
+extends qw(MooseX::App::Cmd::Command);
+
+with qw(
+ GitHub::Collector::Role::Context
+ GitHub::Collector::Role::Logger
+ GitHub::Collector::Role::MongoDB
+);
+
+sub execute {
+ my $self = shift;
+
+ my $edges = $self->db_edges->find();
+
+ my $profiles = {};
+ while ( my $edge = $edges->next ) {
+ $profiles->{ $edge->{target} } += $edge->{weight};
+ }
+
+ foreach my $login ( keys %$profiles ) {
+ $self->db_profiles->update( { login => $login },
+ { '$set' => { indegree => $profiles->{$login} } } );
+ }
+}
+
+1;