diff --git a/app/models/collection.rb b/app/models/collection.rb index 386a703..5edc63e 100644 --- a/app/models/collection.rb +++ b/app/models/collection.rb @@ -116,6 +116,25 @@ def import_org(host, org) end end + def import_awesome_list(url) + lookup_url = "https://awesome.ecosyste.ms/api/v1/lists/lookup?url=#{url}" + resp = Faraday.get(lookup_url) + if resp.status == 200 + data = JSON.parse(resp.body) + projects_url = data['projects_url'] + '?per_page=1000' + resp = Faraday.get(projects_url) + if resp.status == 200 + data = JSON.parse(resp.body) + urls = data.map{|p| p['url'] }.uniq.reject(&:blank?) + urls.each do |url| + puts url + project = projects.find_or_create_by(url: url) + project.sync_async unless project.last_synced_at.present? + end + end + end + end + def import_tag(tag) import_keyword(tag) import_topic(tag)