Hijack requests so we do not stop all reqs while synching

Hijack requests so we do not stop all reqs while synching

From 3d4f7a434a6ebbd42ed94fbceb4641d7d911f17a Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Tue, 27 Nov 2018 20:12:31 +1100
Subject: [PATCH] Hijack requests so we do not stop all reqs while synching


diff --git a/app/controllers/discourse_code_review/code_review_controller.rb b/app/controllers/discourse_code_review/code_review_controller.rb
index 2db768e..f82688d 100644
--- a/app/controllers/discourse_code_review/code_review_controller.rb
+++ b/app/controllers/discourse_code_review/code_review_controller.rb
@@ -34,19 +34,21 @@ module DiscourseCodeReview
       repo = params["repository"]
       repo_name = repo["full_name"] if repo
 
-      if ["commit_comment", "push"].include? type
-        client = DiscourseCodeReview.octokit_client
-        repo = GithubRepo.new(repo_name, client)
-        importer = Importer.new(repo)
-
-        if type == "commit_comment"
-          importer.import_comments
-        elsif type == "push"
-          importer.import_commits
+      hijack do
+        if ["commit_comment", "push"].include? type
+          client = DiscourseCodeReview.octokit_client
+          repo = GithubRepo.new(repo_name, client)
+          importer = Importer.new(repo)
+
+          if type == "commit_comment"
+            importer.import_comments
+          elsif type == "push"
+            importer.import_commits
+          end
         end
-      end
 
-      render plain: '"ok"'
+        render plain: '"ok"'
+      end
     end
 
     def followup

GitHub

1 Like