get_issues 0.1.3 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6e67cc228fa7e173cc929922b1ef9924535302ce6644bf7ef4e3b8cec37ad8be
4
- data.tar.gz: 1abc9e00499a430ea6994b2059138709b0295fe9baa9122c6e595e5328579bc8
3
+ metadata.gz: dd526f5969155a4888e05cac9eb18355cbe558ff8a0272581fbf627b64945ab9
4
+ data.tar.gz: 249b4901046b230deb37abfc1c414f08bddce62ed82e6ed2d5865322816bc1e5
5
5
  SHA512:
6
- metadata.gz: c1970155e3d7edccf11336689c13b753dd26f7581732f1df0b8fde4a037bb9505f3ba72f4b29138085a3142ab71e7eeae25d67bf7bf605801393dd938cc48d32
7
- data.tar.gz: feb5b3e91b80717c60f65196ba0491d942cc554bb860d0550af3ac4190cea49f0299554b03891f76cbe697874c991cf3de694ded7d7203e578cf908ed224ae20
6
+ metadata.gz: 600fa04cb5cbff7992ec67e071085698021925e143efeba90a215950619a000090ecadb738df8cbbfcf2c60ee9799acd1a2f81608e7603f2bc1afed047598c47
7
+ data.tar.gz: 6d1b0b2bc86403828fd4e8b69f05a0e45c70e4b1aea142cfc84f56d26e5c63fb56d4b4618b3b98ebf640aaf123a0c5d19e18b5e9d5511cedd5846231ad1ce1ef
@@ -1,3 +1,3 @@
1
1
  module GetIssues
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.7"
3
3
  end
data/lib/get_issues.rb CHANGED
@@ -4,24 +4,49 @@ require "spreadsheet_architect"
4
4
  module GetIssues
5
5
  class Error < StandardError; end
6
6
 
7
- def self.start(prefix_url, private_token, project_name, mile_stone_title)
8
- projects_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}"`
9
- projects_json = JSON.parse(projects_string)
10
- project_json = projects_json.filter { |t| t["name"] == project_name }&.first
11
- project_id = project_json["id"]
7
+ def self.start_group(prefix_url,private_token,group_name,mile_stone_title)
8
+ groups_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/groups?per_page=1000"`
9
+ groups_json = JSON.parse(groups_string)
10
+ group_json = groups_json.filter { |t| t["name"] == group_name }&.first || {}
11
+ group_id = group_json["id"]
12
+ if group_id.nil?
13
+ p "找不到group"
14
+ end
12
15
 
13
- milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/#{project_id}/milestones"`
16
+ milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/groups/#{group_id}/milestones?per_page=1000"`
14
17
  milestones_json = JSON.parse(milestones_string)
15
18
  mile_stone_json = milestones_json.filter { |t| t["title"] == mile_stone_title }&.first
16
19
  mile_stone_id = mile_stone_json["id"]
20
+ if mile_stone_id.nil?
21
+ p "找不到mile_stone"
22
+ end
23
+
24
+ issues_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/groups/#{group_id}/milestones/#{mile_stone_id}/issues?per_page=10000"`
25
+ issues_json = JSON.parse(issues_string)
26
+ issues_json
27
+ end
17
28
 
18
- issues_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/#{project_id}/milestones/#{mile_stone_id}/issues"`
29
+ def self.start_project(prefix_url, private_token, project_name, mile_stone_title)
30
+ projects_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/projects?sort=asc&&order_by=name&&simple=true&&per_page=1000"`
31
+ projects_json = JSON.parse(projects_string)
32
+ project_json = projects_json.filter { |t| t["name"] == project_name }&.first || {}
33
+ project_id = project_json["id"]
34
+ if project_id.nil?
35
+ p "找不到project"
36
+ end
37
+ milestones_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/projects/#{project_id}/milestones&&per_page=1000"`
38
+ milestones_json = JSON.parse(milestones_string)
39
+ mile_stone_json = milestones_json.filter { |t| t["title"] == mile_stone_title }&.first || {}
40
+ mile_stone_id = mile_stone_json["id"]
41
+ if mile_stone_id.nil?
42
+ p "找不到mile_stone"
43
+ end
44
+ issues_string = `curl --header "PRIVATE-TOKEN: #{private_token}" "#{prefix_url}/projects/#{project_id}/milestones/#{mile_stone_id}/issues?per_page=10000"`
19
45
  issues_json = JSON.parse(issues_string)
20
46
  issues_json
21
47
  end
22
48
 
23
- def self.to_xlsx(prefix_url, private_token, project_name, mile_stone_title)
24
- issues_json = start(prefix_url, private_token, project_name, mile_stone_title)
49
+ def self.to_xlsx(issues_json,mile_stone_title)
25
50
  data = []
26
51
  issues_json.each do |issue|
27
52
  assignes_names = issue["assignees"]&.map { |t| t["name"]&.split(" ")&.reverse&.join("") }&.join(",")
@@ -35,6 +60,14 @@ module GetIssues
35
60
  f.write file_data
36
61
  end
37
62
  end
63
+ def self.to_xlsx_group(prefix_url,private_token,group_name,mile_stone_title)
64
+ issues_json = start_group(prefix_url,private_token,group_name,mile_stone_title)
65
+ to_xlsx(issues_json,mile_stone_title)
66
+ end
67
+ def self.to_xlsx_project(prefix_url, private_token, project_name, mile_stone_title)
68
+ issues_json = start_project(prefix_url, private_token, project_name, mile_stone_title)
69
+ to_xlsx(issues_json,mile_stone_title)
70
+ end
38
71
  # 定义xlsx文件格式的头样式
39
72
  def self.init_header_style
40
73
  { height: 75, background_color: "458B00", color: "FFFFFF", align: :center, font_name: "Arial", font_size: 14, bold: false, italic: false, underline: false }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: get_issues
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - '807715333'
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-08-23 00:00:00.000000000 Z
11
+ date: 2021-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler