Browse files

got something, but it is not quite it

  • Loading branch information...
1 parent d4cdb82 commit e4b47b6b6adb1613e3669b3d62ab7f7f1549df38 @maxdemarzi committed Mar 25, 2012
Showing with 60 additions and 10 deletions.
  1. +50 −0 hive_plot.rb
  2. +10 −10 public/main.js
View
50 hive_plot.rb
@@ -2,4 +2,54 @@
require 'neography'
require 'sinatra'
require 'uri'
+require 'json'
+def wroterepos(language)
+ neo = Neography::Rest.new
+ neo.execute_script("m = [:]
+ g.V.filter{it.type == 'language' && it.name == '#{language}'}.in.transform{m[it.name] = it.in('wrote').gather{it.name}.next()}.iterate()
+ m")
+end
+
+def forkedrepos(language)
+ neo = Neography::Rest.new
+ neo.execute_script("m = [:]
+ g.V.filter{it.type == 'language' && it.name == '#{language}'}.in.transform{m[it.name] = it.in('forked').gather{it.name}.next()}.iterate()
+ m")
+end
+
+get '/hive/:name' do
+ repos = []
+ writers = []
+ forkers = []
+ temp_forkers = []
+ temp_writers = []
+
+ wroterepos(params[:name]).each_pair do |key, value|
+ repos << {"name" => key, "imports" => value}
+ temp_writers << { "name" => value[0] }
+ end
+
+ i = 0
+ forkedrepos(params[:name]).each_pair do |key, value|
+ repos[i]["imports"] = repos[i]["imports"] + value
+ temp_writers[i]["imports"] = value
+ temp_forkers << value
+ i += 1
+ end
+
+ temp_writers.group_by {|i| i["name"]}.each do |w, f|
+ writers << {"name" => w, "imports" => f.collect{|y| y["imports"]}.flatten.uniq}
+ end
+
+ puts writers.inspect # collect{|y| y["name"]}.inspect
+
+ temp_forkers.flatten.uniq.delete_if{|x| writers.collect{|y| y["name"]}.include?(x)}.each do |f|
+ forkers << {"name" => f, "imports" => []}
+ end
+ puts "-------------------"
+ puts forkers.inspect
+
+ (repos + writers + forkers).to_json
+
+end
View
20 public/main.js
@@ -10,15 +10,15 @@
x_max = 250,
y_max = 220;
- var demos = { '#hv_1_1': 'ze_data.json',
- '#hv_1_2': 'ze_test.json',
- '#hv_1_3': 'ze_test.json',
- '#hv_2_1': 'ze_test.json',
- '#hv_2_2': 'ze_test.json',
- '#hv_2_3': 'ze_test.json',
- '#hv_3_1': 'ze_test.json',
- '#hv_3_2': 'ze_test.json',
- '#hv_3_3': 'ze_test.json' };
+ var demos = { '#hv_1_1': '/hive/Boo',
+ '#hv_1_2': '/hive/Dylan',
+ '#hv_1_3': '/hive/Factor',
+ '#hv_2_1': '/hive/Gosu',
+ '#hv_2_2': '/hive/Mirah',
+ '#hv_2_3': '/hive/Nemerle',
+ '#hv_3_1': '/hive/Nu',
+ '#hv_3_2': '/hive/Parrot',
+ '#hv_3_3': '/hive/Self' };
for (var demo in demos) {
@@ -34,7 +34,7 @@
'axes': {
'source': { 'angle': degree * 0 },
- 'source-target': { 'angle': degree * 120 },
+ 'target-source': { 'angle': degree * 120 },
'target': { 'angle': degree * 240 }
}
};

0 comments on commit e4b47b6

Please sign in to comment.