lib/ghtorrent/ghtorrent.rb
def ensure_issues(owner, repo)
      currepo = ensure_repo(owner, repo)
      if currepo.nil?
        warn "Could not find repo #{owner}/#{repo} for retrieving issues"
        return
      end

      issues = db[:issues].filter(:repo_id => currepo[:id]).all
      raw_issues = retrieve_issues(owner, repo).reduce([]) do |acc, x|
                     if issues.find { |y| y[:issue_id] == x['number'] }.nil?
                       acc << x
                     else
                         acc
                     end
                   end

      raw_issues.map { |x| save { ensure_issue(owner, repo, x['number']) } }.select { |x| !x.nil? }
    end
def ensure_issues(owner, repo)
      currepo = ensure_repo(owner, repo)
      if currepo.nil?
        warn "Could not find repo #{owner}/#{repo} for retrieving issues"
        return
      end

      issues = db[:issues].filter(:repo_id => currepo[:id]).all
      raw_issues = retrieve_issues(owner, repo).reduce([]) do |acc, x|
                     if issues.find { |y| y[:issue_id] == x['number'] }.nil?
                       acc << x
                     else
                         acc
                     end
                   end

      raw_issues.map { |x| save { ensure_issue(owner, repo, x['number']) } }.select { |x| !x.nil? }
    end
Make sure all issues exist for a project