kou commented on code in PR #33791:
URL: https://github.com/apache/arrow/pull/33791#discussion_r1083240407


##########
dev/release/02-source-test.rb:
##########
@@ -93,33 +93,26 @@ def test_python_version
   end
 
   def test_vote
-    jira_url = "https://issues.apache.org/jira";
-    jql_conditions = [
-      "project = ARROW",
-      "status in (Resolved, Closed)",
-      "fixVersion = #{@release_version}",
-    ]
-    jql = jql_conditions.join(" AND ")
+    github_token = ENV["ARROW_GITHUB_API_TOKEN"]
+    uri = URI.parse("https://api.github.com/graphql";)
+    https = Net::HTTP.new(uri.host, uri.port)
+    https.use_ssl = true
+    req = Net::HTTP::Post.new(uri.path, initheader = {"Authorization" => 
"Bearer #{github_token}"})
+
+    n_issues_query = "{\"query\":\"query {search(query: \\\"repo:apache/arrow 
is:issue is:closed milestone:#{@release_version}\\\", type:ISSUE) 
{issueCount}}\"}"
+    req.body = n_issues_query
     n_resolved_issues = nil
-    search_url = URI("#{jira_url}/rest/api/2/search?jql=#{CGI.escape(jql)}")
-    search_url.open do |response|
-      n_resolved_issues = JSON.parse(response.read)["total"]
+    https.request(req) do |response|
+        n_resolved_issues = 
JSON.parse(response.body)["data"]["search"]["issueCount"]
     end

Review Comment:
   We can use `Net::HTTP.post`:
   
   ```ruby
   uri = URI.parse("https://api.github.com/graphql";)
   n_issues_query = {
     "query" => <<-QUERY,
       query {
         search(query: "repo:apache/arrow is:issue is:closed 
milestone:#{@release_version}",
                type: ISSUE) {
           issueCount
         }
       }
     QUERY
   }
   response = Net::HTTP.post(uri,
                             n_issues_query.to_json,
                             "Content-Type" => "application/json",
                             "Authorization" => "Bearer #{github_token}")
   n_resolved_issues = JSON.parse(response.body)["data"]["search"]["issueCount"]
   ```



##########
dev/release/02-source-test.rb:
##########
@@ -93,33 +93,26 @@ def test_python_version
   end
 
   def test_vote
-    jira_url = "https://issues.apache.org/jira";
-    jql_conditions = [
-      "project = ARROW",
-      "status in (Resolved, Closed)",
-      "fixVersion = #{@release_version}",
-    ]
-    jql = jql_conditions.join(" AND ")
+    github_token = ENV["ARROW_GITHUB_API_TOKEN"]
+    uri = URI.parse("https://api.github.com/graphql";)
+    https = Net::HTTP.new(uri.host, uri.port)
+    https.use_ssl = true
+    req = Net::HTTP::Post.new(uri.path, initheader = {"Authorization" => 
"Bearer #{github_token}"})
+
+    n_issues_query = "{\"query\":\"query {search(query: \\\"repo:apache/arrow 
is:issue is:closed milestone:#{@release_version}\\\", type:ISSUE) 
{issueCount}}\"}"
+    req.body = n_issues_query
     n_resolved_issues = nil
-    search_url = URI("#{jira_url}/rest/api/2/search?jql=#{CGI.escape(jql)}")
-    search_url.open do |response|
-      n_resolved_issues = JSON.parse(response.read)["total"]
+    https.request(req) do |response|
+        n_resolved_issues = 
JSON.parse(response.body)["data"]["search"]["issueCount"]
     end
-    github_api_url = "https://api.github.com";
-    verify_prs = URI("#{github_api_url}/repos/apache/arrow/pulls" +
-                     "?state=open" +
-                     "&head=apache:release-#{@release_version}-rc0")
+
+    pr_query = "{\"query\": \"query {repository(owner: \\\"apache\\\", name: 
\\\"arrow\\\") {refs(first: 1, refPrefix: \\\"refs/heads/\\\", query: 
\\\"release-#{@release_version}-rc0\\\") {nodes{associatedPullRequests(first: 
1){edges{node{url}}}}}}}\"}"
+    req.body = pr_query
     verify_pr_url = nil
-    headers = {
-      "Accept" => "application/vnd.github+json",
-    }
-    github_token = ENV["ARROW_GITHUB_API_TOKEN"]
-    if github_token
-      headers["Authorization"] = "Bearer #{github_token}"
-    end
-    verify_prs.open(headers) do |response|
-      verify_pr_url = (JSON.parse(response.read)[0] || {})["html_url"]
+    https.request(req) do |response|
+      verify_pr_url = 
JSON.parse(response.body)["data"]["repository"]["refs"]["nodes"][0]["associatedPullRequests"]["edges"][0]["node"]["url"]
     end
+

Review Comment:
   Do we need to change this? It seems that we can still use the current simple 
REST API.



##########
dev/release/02-source.sh:
##########
@@ -142,18 +142,18 @@ if [ ${SOURCE_PR} -gt 0 ]; then
 fi
 
 if [ ${SOURCE_VOTE} -gt 0 ]; then
-  jira_url="https://issues.apache.org/jira";
-  
jql="project%20%3D%20ARROW%20AND%20status%20in%20%28Resolved%2C%20Closed%29%20AND%20fixVersion%20%3D%20${version}"
-  n_resolved_issues=$(curl "${jira_url}/rest/api/2/search/?jql=${jql}" | jq 
".total")
-  curl_options=(--header "Accept: application/vnd.github+json")
-  if [ -n "${ARROW_GITHUB_API_TOKEN:-}" ]; then
-    curl_options+=(--header "Authorization: Bearer ${ARROW_GITHUB_API_TOKEN}")
-  fi
-  curl_options+=(--get)
-  curl_options+=(--data "state=open")
-  curl_options+=(--data "head=apache:${rc_branch}")
-  curl_options+=(https://api.github.com/repos/apache/arrow/pulls)
-  verify_pr_url=$(curl "${curl_options[@]}" | jq -r ".[0].html_url")

Review Comment:
   Do we need to change this? It seems that we can still use the current simple 
REST API.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to