Skip to content

Instantly share code, notes, and snippets.

@plotti
Created June 12, 2012 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plotti/2916063 to your computer and use it in GitHub Desktop.
Save plotti/2916063 to your computer and use it in GitHub Desktop.
Comparing the rankings of the members
#Second step is to output the final partitions according to the ranking of the persons in their groups
seen_persons = []
final_candidates = {}
seen_projects = []
@@communities.each do |community|
project = Project.find(community)
if merged[project.name] == nil
project_members = members[project.name]
project_name = project.name
else
project_members = members[merged[project.name]]
project_name = merged[project.name]
end
if !seen_projects.include? project_name
puts "Computing places on project name: #{project_name}"
seen_projects << project_name
else
puts "Skippng #{project_name}"
next
end
project_members.each do |person|
if !seen_persons.include? person[0]
#puts "Working on person #{person[0]}"
min_list_place,original_list_place,membership,memberships = 10000,0,"",[]
members.each do |key,value|
if merged[key] != nil
next
end
if value[person[0]] != nil # we have found a matching person in the lists
memberships += [key,value[person[0]][:rank]]
original_list_place = value[person[0]][:rank] if key == project_name
membership, min_list_place = key,value[person[0]][:rank] if value[person[0]][:rank] < min_list_place
end
end
seen_persons << person[0]
outfile << [person[0], project_name, original_list_place, membership, min_list_place, memberships.count/2, memberships.join(",")]
final_candidates[membership] ||= []
final_candidates[membership] << {:name => person[0], :rank => min_list_place, :competing_memberships => memberships.count/2}
end
end
end
#Output the final partition
final_candidates.each do |key,value|
value.sort{|a,b| a[:rank]<=>b[:rank]}[0..PARTITION_MAX].each do |member|
final_partition << [member[:name],key,member[:rank],member[:competing_memberships]]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment