0

I'm using Octokit.rb to search GitHub users and the response returns a Sawyer::Resource object. I'm currently accessing the data this way:

[].tap do |users|
  @results.items.each do |item|
    user = item.rels[:self].get.data
    user = { 
      location: user.location, 
      username: user.login, 
      name: user.name, 
      email: user.email 
    }

    users << user
  end
end

I'd like to iterate over the users array created and display the results, however, right now the method takes extremely long as a result of accessing the data thru #rels[:self].get.data and I'm not sure what to do. Any help would be greatly appreciated!

RailsGuy428
  • 5
  • 1
  • 4
  • 1
    Looks like someone [opened an issue](https://github.com/octokit/octokit.rb/issues/416) for this in the [octokit/octokit.rb](https://github.com/octokit/octokit.rb) GitHub repo. Cool. Linking to it here for reference: https://github.com/octokit/octokit.rb/issues/416 – jasonrudolph Jan 27 '14 at 16:35
  • Ya it seems that there is no workaround for this... One thing I'm curious about though is it seems that accessing the same user from item.rels[:self].get.data and Octokit.user('user') are not viewed as a request for the same resource in terms of caching. I'm not sure if I'm caching incorrectly. Do you think the best way to do this would be to seed my database with every GitHub user so that the resources are cached? Or would they only be cached on my machine? I'm unsure of how this works, never used an HTTP cache before. – RailsGuy428 Jan 27 '14 at 17:11
  • I'm going to do some reading on concurrent requests, but I think GitHub's search API has a rate limit of 20 per minute. – RailsGuy428 Jan 27 '14 at 17:27

1 Answers1

1

Hey so I started messing around with the Octokit.rb library yesterday after I saw your question and I actually ran into the same issue as Jason pointed out. You're on the right track about using concurrent requests. I'm not sure about the rate limit being an issue and if it is you could always contact Github and ask if they could up your limit. If you're still having issues I would recommend using the rest-more gem, which uses rest-core to make concurrent requests. Its really simple to setup just read the docs.

evkline
  • 1,451
  • 3
  • 16
  • 34