Skip to content

Commit

Permalink
got something, but it is not quite it
Browse files Browse the repository at this point in the history
  • Loading branch information
maxdemarzi committed Mar 25, 2012
1 parent d4cdb82 commit e4b47b6
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 10 deletions.
50 changes: 50 additions & 0 deletions hive_plot.rb
Expand Up @@ -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
20 changes: 10 additions & 10 deletions public/main.js
Expand Up @@ -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) {

Expand All @@ -34,7 +34,7 @@

'axes': {
'source': { 'angle': degree * 0 },
'source-target': { 'angle': degree * 120 },
'target-source': { 'angle': degree * 120 },
'target': { 'angle': degree * 240 }
}
};
Expand Down

0 comments on commit e4b47b6

Please sign in to comment.