From 9437b8a2e4ae4c688272d0febfbca4007232e4f5 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Wed, 18 May 2016 16:14:20 -0500 Subject: Import GitHub repositories respecting the API rate limit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While Octokit auto pagination set the page size to the maximum 100, and seek to not overstep the rate limit. When the rate limit is reached its raises an exception, and stop doing new requests. Here we use a custom pattern for traversing large lists, so we can check if we’ll reach the rate limit and wait the API to reset the rate limit before making new requests. --- lib/gitlab/github_import/label_formatter.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/gitlab/github_import/label_formatter.rb') diff --git a/lib/gitlab/github_import/label_formatter.rb b/lib/gitlab/github_import/label_formatter.rb index c2b9d40b511..87b51a0a178 100644 --- a/lib/gitlab/github_import/label_formatter.rb +++ b/lib/gitlab/github_import/label_formatter.rb @@ -9,6 +9,10 @@ module Gitlab } end + def create! + Label.create!(self.attributes) + end + private def color -- cgit v1.2.1 From 67c02edccf2dc3d42126dcf4269862c2a1622fff Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Mon, 6 Jun 2016 14:00:44 -0300 Subject: Move create! method from formatters to the BaseFormatter --- lib/gitlab/github_import/label_formatter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/gitlab/github_import/label_formatter.rb') diff --git a/lib/gitlab/github_import/label_formatter.rb b/lib/gitlab/github_import/label_formatter.rb index 87b51a0a178..9f18244e7d7 100644 --- a/lib/gitlab/github_import/label_formatter.rb +++ b/lib/gitlab/github_import/label_formatter.rb @@ -9,8 +9,8 @@ module Gitlab } end - def create! - Label.create!(self.attributes) + def klass + Label end private -- cgit v1.2.1