Skip to content

Commit

Permalink
method for importing from an awesome list
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew committed Jul 25, 2024
1 parent 1185d6f commit 864358c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/models/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 864358c

Please sign in to comment.