Skip to content

Commit

Permalink
allow entering of auth token so we do not hit rate limits so hard
Browse files Browse the repository at this point in the history
  • Loading branch information
SamSaffron committed Nov 20, 2018
1 parent b5fd413 commit 55d57a7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins:
code_review_enabled: false
code_review_github_repo: ""
code_review_api_username: ""
code_review_pending_category_id:
hidden: true
default: -1
Expand Down
18 changes: 16 additions & 2 deletions plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,24 @@ def self.current_comment_page=(v)

MAX_DIFF_LENGTH = 8000

def self.octokit_client
client = Octokit::Client.new

if username = SiteSetting.code_review_api_username.presence
username = username.downcase
id = User.where(username_lower: username).pluck(:id).first
if id && (token = UserCustomField.where(user_id: id, name: DiscourseCodeReview::UserToken).pluck(:value).first)
client = Octokit::Client.new(access_token: token)
end
end

client
end

def self.commit_comments(page = nil)
page ||= DiscourseCodeReview.current_comment_page

Octokit.list_commit_comments(SiteSetting.code_review_github_repo, page: page).map do |hash|
octokit_client.list_commit_comments(SiteSetting.code_review_github_repo, page: page).map do |hash|

line_content = nil

Expand Down Expand Up @@ -144,7 +158,7 @@ def self.commits_since(hash = nil)
commits = git("log #{hash}.. --pretty=%H").split("\n").map { |x| x.strip }

commits.each_slice(30).each do |x|
commits = Octokit.commits(SiteSetting.code_review_github_repo, sha: x.first)
commits = octokit_client.commits(SiteSetting.code_review_github_repo, sha: x.first)
github_info.concat(commits)
end

Expand Down

0 comments on commit 55d57a7

Please sign in to comment.