app/jobs/github_repos_wrapper.rb
# TODO: refactor for method composition and readability
refactor for method composition and readability
refactor for method composition and readability
def handle_request
        repos_batch = parse_repos
        @repos << repos_batch
        create_repos if @repos.length >= BATCHES_TO_MERGE
        next_url =  @resp.headers['link'].split(',').first.split(';').first[/(?<=<).*(?=>)/]
        next_id = next_url.split('=').last.to_i
        if @stop_id && @stop_id < next_id
          puts "Stopping requests and exiting: stop limit reached at id:#{next_id}"
          abort
        end
        @current_url = next_url
    end
def handle_request repos_batch = parse_repos @repos << repos_batch create_repos if @repos . length >= BATCHES_TO_MERGE next_url = @resp . headers [ 'link' ] . split ( ',' ) . first . split ( ';' ) . first [ / (?<=<).*(?=>) / ] next_id = next_url . split ( '=' ) . last . to_i if @stop_id && @stop_id < next_id puts "Stopping requests and exiting: stop limit reached at id:#{next_id}" abort end @current_url = next_url end
TODO: refactor for method composition and readability
TODO : refactor for method composition and readability
# TODO: We can speed this up by saving more records, say 1000 in memory before importing to the database