Skip to content

Commit

Permalink
Add projects
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Nov 15, 2023
1 parent b514aa5 commit e037e8b
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions bin/workflows-fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ def fetch_workflows(server)
end

def fetch_workflowhub()
projects = JSON.parse(request("https://workflowhub.eu/projects").body)
project_mapping = projects['data'].map{|p| [p['id'], p['attributes']['title']]}.to_h

response = request("https://workflowhub.eu/workflows?filter[workflow_type]=galaxy")
data = JSON.parse(response.body)
if !data['links']['next'].nil?
Expand All @@ -38,23 +41,32 @@ def fetch_workflowhub()
data['data'].map.with_index { |w, i|
# {"id"=>"14", "type"=>"workflows", "attributes"=>{"title"=>"Cheminformatics - Docking"}, "links"=>{"self"=>"/workflows/14"}}
wf_info = JSON.parse(request("https://workflowhub.eu#{w['links']['self']}").body)
creator_list = []

creator0 = wf_info['data']['attributes']['creators'][0]
owner = ""
if !creator0.nil?
owner = creator0['given_name'] + " " + creator0['family_name']
# Primary
creator_list.push(creator0['given_name'] + " " + creator0['family_name'])
else
# Other creators
other = wf_info['data']['attributes']['other_creators']
if !other.nil? && other.length.positive?
owner = wf_info['data']['attributes']['other_creators']
creator_list.push(wf_info['data']['attributes']['other_creators'].split(',').map{|x| x.strip})
else
owner = "Unknown"
end
end
# Projects
wf_info['data']['relationships']['projects']['data'].each do |p|
creator_list.push(project_mapping[p['id']])
end

creator_list = creator_list.flatten.compact.uniq

begin
r = {
'name' => wf_info['data']['attributes']['title'],
'owner' => owner,
'owner' => creator_list.join(', '),
'number_of_steps' => wf_info['data']['attributes']['internals']['steps'].length,
'server' => 'https://workflowhub.eu',
'id' => wf_info['data']['id'],
Expand Down

0 comments on commit e037e8b

Please sign in to comment.