-
-
Notifications
You must be signed in to change notification settings - Fork 501
/
Copy pathModule1.bas
131 lines (104 loc) · 3.5 KB
/
Module1.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
Attribute VB_Name = "Module1"
Sub Button1_Click()
Dim PrevUpdating As Boolean
Dim LastIndex As Integer
PrevUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False
LastIndex = 1
GetIssues ActiveSheet.Cells(1, 2), LastIndex
Application.ScreenUpdating = PrevUpdating
End Sub
Sub Button2_Click()
Dim PrevUpdating As Boolean
Dim LastIndex As Integer
PrevUpdating = Application.ScreenUpdating
Application.ScreenUpdating = False
LastIndex = 1
GetProjects
Application.ScreenUpdating = PrevUpdating
End Sub
Sub GetIssues(ProjectId As Long, Optional ByRef LastIndex As Integer = 1, Optional LastPage As Integer = 1)
Dim Issues As Object
Dim Assignee As Object
Dim Sheet As Worksheet
Set Issues = gitlab.GetIssiues(ProjectId, LastPage)
Set Sheet = Worksheets("issues")
If (LastIndex = 1) Then
Sheet.UsedRange.Clear
Sheet.Cells(1, 1) = "project_id"
Sheet.Cells(1, 2) = "id"
Sheet.Cells(1, 3) = "iid"
Sheet.Cells(1, 4) = "title"
Sheet.Cells(1, 5) = "state"
Sheet.Cells(1, 6) = "assignee.name"
Sheet.Cells(1, 7) = "created_at"
Sheet.Cells(1, 8) = "closed_at"
LastIndex = LastIndex + 1
End If
For Each Issue In Issues
Sheet.Cells(LastIndex, 1) = ProjectId
Sheet.Cells(LastIndex, 2) = Issue("id")
Sheet.Cells(LastIndex, 3) = Issue("iid")
Sheet.Cells(LastIndex, 4) = Issue("title")
Sheet.Cells(LastIndex, 5) = Issue("state")
If Not IsNull(Issue("assignee")) Then
Set Assignee = Issue("assignee")
Sheet.Cells(LastIndex, 6) = Assignee("name")
End If
Sheet.Cells(LastIndex, 7) = FormatDate(Issue("created_at"))
Sheet.Cells(LastIndex, 8) = FormatDate(Issue("closed_at"))
LastIndex = LastIndex + 1
Next Issue
If LastIndex = LastPage * 100 + 2 Then
GetIssues ProjectId, LastIndex, LastPage + 1
End If
End Sub
Sub GetProjects()
Dim Projects As Object
Dim Assignee As Object
Dim Sheet As Worksheet
Dim LastIndex As Integer
Set Projects = gitlab.GetProjects()
Set Sheet = Worksheets("projects")
Sheet.UsedRange.Clear
Sheet.Cells(1, 1) = "id"
Sheet.Cells(1, 2) = "name"
LastIndex = 2
For Each Project In Projects
Sheet.Cells(LastIndex, 1) = Project("id")
Sheet.Cells(LastIndex, 2) = Project("name")
LastIndex = LastIndex + 1
Next Project
End Sub
Sub GetEvents()
Dim Events As Object
Dim Assignee As Object
Dim Sheet As Worksheet
Dim i As Integer
Set Events = gitlab.GetEvents
Set Sheet = Worksheets("events")
Sheet.UsedRange.Clear
Sheet.Cells(1, 1) = "issue_id"
Sheet.Cells(1, 2) = "action_name"
Sheet.Cells(1, 3) = "created_at"
i = 2
For Each Evnt In Events
Sheet.Cells(i, 1) = Evnt("target_id")
Sheet.Cells(i, 2) = Evnt("action_name")
Sheet.Cells(i, 3) = Evnt("created_at")
i = i + 1
Next Evnt
End Sub
Function Decode(value As String) As String
value = Replace(value, "ş", "s")
value = Replace(value, "ı", "i")
value = Replace(value, "İ", "I")
Decode = value
End Function
Function FormatDate(value As Variant) As String
If IsNull(value) Or IsEmpty(value) Then
FormatDate = ""
Else
FormatDate = Mid(value, 9, 2) & "." & Mid(value, 6, 2) & ". " & Mid(value, 1, 4) & " " & Mid(value, 12, 8)
End If
End Function