Skip to content

Commit c22f7fe

Browse files
committed
<∆QuickView> and <∆Details> improved
1 parent 6d92d13 commit c22f7fe

File tree

10 files changed

+188
-98
lines changed

10 files changed

+188
-98
lines changed

APLSource/GitHubAPIv3.aplc

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,30 @@
1414
:Access Public Shared
1515
:If 0<##.⎕NC'TatinVars.CONFIG'
1616
r←(⎕JSON⍠('Dialect' 'JSON5')⊢##.TatinVars.CONFIG).version
17-
:ElseIf 0<##.##.⎕NC'TatinVars.CONFIG'
18-
r←(⎕JSON⍠('Dialect' 'JSON5')⊢##.##.TatinVars.CONFIG).version
1917
:Else
20-
⍝ When a script was not loaded with Tatin, there will be no namespace `TatinVars`.
21-
⍝ In such cases we cannot provide a version number, so we return just ''.
18+
⍝ When a script was not loaded with Tatin, there will be no namespace `TatinVars`.
19+
⍝ In such cases we cannot provide a version number, so we return just ''.
2220
r←''
2321
:EndIf
2422
2523

2624
∇ History
2725
:Access Public Shared
26+
⍝ * 2.1.0 from 2025-04-21
27+
⍝ * Function `GetIssues` added
28+
⍝ * Function `GetLabelStats` added
29+
⍝ * `∆QuickView` (injected into issues) does not require an argument anymore & returns the creation date now as well
30+
⍝ * `∆Details` (injected into issues) does not require an argument anymore
31+
⍝ * Bug fixes
32+
⍝ * Typo fixed in `Version`
33+
⍝ * Empty "owner" was accepted by `⎕NEW` - makes no sense
2834
⍝ * 2.0.0 from 2025-04-09
29-
⍝ * Potentially breaking: `Version` now returns a char vector temming from the package config file
35+
⍝ * Potentially breaking: `Version` now returns a char vector stemming from the package config file
3036
⍝ * Packages updated
3137
⍝ * "Make" improved
3238
⍝ * 1.6.0 from 2025-01-025
3339
⍝ * CommTools removed as a dependency - it was only required for tests
3440
⍝ * `Version` now returns the package config file setting
35-
⍝ * 1.5.0 from 2024-11-16
36-
⍝ * `CheckForUpdate` can now handle beta versions on the client side (on GitHub, betas are not supported)
37-
⍝ * 1.4.0 from 2024-09-24
38-
⍝ * New instance method `GetMyRateLimits` added whbich complements the older shared method `GetRateLimits`
39-
⍝ * BREAKING CHANGE
40-
⍝ The instance property `pathToConngaDLLs` has been removed and replaced by an instance field with the same name.
41-
⍝ This syntax change was necessary because some shared methods (`GetAllEndPoints`, `GetRateLimits`) called `GetJson`
42-
⍝ which relies on `pathToCongaDLLs` being defined. It affects you only when you have set `pathToCongaDLLs` as a
43-
⍝ property of an instance, because that needs changing: assign it to the field of the class instead.
44-
⍝ * `GetAllTopics` called `GetJson` with a left argument
45-
⍝ * 1.3.0 from 2024-09-23
46-
⍝ * There was no way to specify a path for the Conga DLLs in GetJson: now there is a field `path2CongaDLLs`
47-
⍝ * Bug fixes
48-
⍝ * `GetRelease` did not process its (optional) left argument correctly, resulting in a crash.
49-
⍝ * Shared method `GetJson` relied on instance property `path2CongaDLLs`. Can now be specified as left argument
50-
⍝ * The function `GetJson` had an optional left argument `parms` that was never processed: removed.
5141
⍝\\
5242
⍝ For information regarding older versions see <https://github.com/aplteam/GitHubAPIv3/releases>
5343
@@ -75,7 +65,7 @@
7565
∇ make1(owner)
7666
:Access Public Instance
7767
:Implements Constructor
78-
_owner←owner
68+
'"Owner" must not be empty'Assert 0<≢_owner←owner~' '
7969
_personal_access_token←''
8070
_regEx←'setup_<repoName>_<version>[.\]*.[0-9]{0,6}\.exe' ⍝ After version there _might_ be a built number
8171
A←(⊃⊃⎕CLASS ⎕THIS).##.APLTreeUtils2
@@ -179,8 +169,39 @@
179169
:EndIf
180170
ns.⎕DF(repoName,' issue ')∘,¨(⍕¨ns.number)
181171
ns.⎕FX⊂⎕CR'∆List'
182-
ns.⎕FX⊂'r←∆Details instance' 'r←∆List' ' :If 0<≢instance' 'r(instance.GetPrincipal)←''assignees'' ''login''' 'r(instance.GetPrincipal)←''labels'' ''name''' ':EndIf'
183-
ns.⎕FX⊂'r←∆QuickView instance;keyWords' 'r←∆Details instance' 'keyWords←''title'' ''number'' ''state'' ''updated_at'' ''labels'' ''assignees''' 'r←(r[;1]∊keyWords)⌿r' 'r←r[⍋keyWords⍳r[;1];]'
172+
ns.⎕FX⊂'r←∆Details;ind' '⍝ Like <List> but with greatly improved readability' 'r←∆List' 'r(⎕THIS.##.GetPrincipal)←''assignees'' ''login''' 'r(⎕THIS.##.GetPrincipal)←''labels'' ''name''' 'r[⍸r[;2]≡¨⊂⊂''null'';2]←⊂''''' ':If 0<≢ind←⍸r[;1]∊''created_at'' ''updated_at''' 'r[ind;2]←{r←⍵ ⋄ r[11]←'' '' ⋄ r}¨r[ind;2]' ':EndIf'
173+
ns.⎕FX⊂'r←∆QuickView;keyWords;ind' '⍝ Provides the most common pieces of information' 'r←∆Details' 'keyWords←''title'' ''number'' ''state'' ''created_at'' ''updated_at'' ''labels'' ''assignees''' 'r←(r[;1]∊keyWords)⌿r' 'r←r[⍋keyWords⍳r[;1];]' ':If 0<≢ind←⍸r[;1]∊''created_at'' ''updated_at''' 'r[ind;2]←{r←⍵ ⋄ r[11]←'' '' ⋄ r}¨r[ind;2]' ':EndIf'
174+
:EndIf
175+
176+
177+
∇ r←GetIssues repoName;issues;labels
178+
⍝ Get a matrix with all issues.\\
179+
⍝ [;1] Issue number\\
180+
⍝ [;2] Creation date
181+
⍝ [;3] Title
182+
⍝ [;4] Label(s) assigned
183+
:Access Public Instance
184+
:If 0=≢issues←GetAllIssues repoName
185+
r←0 4⍴⊂''
186+
:Else
187+
labels←{2::'' ⋄ ⊃{⍺,',',⍵}/⍵.name}¨issues.labels
188+
r←issues.number,↑issues.(created_at title)
189+
r,←labels
190+
r[;2]←{r←↑⍵ ⋄ r[;11]←' ' ⋄ ↓r}r[;2]
191+
:EndIf
192+
193+
194+
∇ r←GetLabelStats repoName;issues;labels
195+
⍝ Get a matrix with all labels assigned to issues in [;1] and the count in [;2]
196+
:Access Public Instance
197+
:If 0=≢issues←GetAllIssues repoName
198+
r←0 2⍴⊂''
199+
:Else
200+
labels←⊃,/{2::⊂'<no label>' ⋄ ⍵.name}¨issues.labels
201+
labels←labels{(⍵↓⍺),(⍵↑⍺)}+/'<no label>'∘≡¨labels
202+
r←{⍺(≢⍵)}⌸labels
203+
r[;1]←⊃¨r[;1]
204+
r←r[⍒r[;2];]
184205
:EndIf
185206
186207

@@ -332,6 +353,7 @@
332353
r.Accepted←'Accept: application/vnd.github.v3+json'
333354
r.Method←'GET'
334355
r.Body←''
356+
⍝CodeCoverage:ignore⍝
335357
336358

337359
⍝ ------------------------------------------ Private stuff ----------------------------------
@@ -366,7 +388,7 @@
366388
h.CongaPath←path2CongaDLLs
367389
:EndIf
368390
r←h.Run
369-
(r.HttpMessage,' (',(⍕r.HttpStatus),')')Assert r.HttpStatus=200
391+
(r.HttpMessage,' (',(⍕r.HttpStatus),')')Assert r.HttpStatus200
370392
data←⎕JSON r.Data
371393
noOfPages←GetNoOfPages r.Headers
372394
:If 0<noOfPages
@@ -375,15 +397,15 @@
375397
link←2⊃r.Headers[ind;]
376398
h.URL←{¯1↓1↓⍵↑⍨¯1+⍵⍳';'}link
377399
r2←h.Run
378-
(r.HttpMessage,' (',(⍕r.HttpStatus),')')Assert r.HttpStatus=200
400+
(r.HttpMessage,' (',(⍕r.HttpStatus),')')Assert r.HttpStatus200
379401
data,←⎕JSON r2.Data
380402
:If 2<noOfPages
381403
⍝ Fetch all remaining pages
382404
links←({¯2↓1↓⍵↑⍨¯1+⍵⍳';'}link)∘{⍺,⍕⍵}¨2↓⍳noOfPages
383405
:For link :In links
384406
h.URL←link
385407
r2←h.Run
386-
(r.HttpMessage,' (',(⍕r.HttpStatus),')')Assert r.HttpStatus=200
408+
(r.HttpMessage,' (',(⍕r.HttpStatus),')')Assert r.HttpStatus200
387409
data,←⎕JSON r2.Data
388410
:EndFor
389411
:EndIf

APLSource/TestCases/Test_Issue_010.aplf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
data←∆MyGitHubAPI.GetAllIssues'TestRepo'
77
→T.PassesIf 1=⍴⍴data.∆List
88
→T.PassesIf∧/2∧.=¨⍴∘⍴¨data.∆List
9-
→T.PassesIf 1=⍴⍴data.∆Details ∆MyGitHubAPI
10-
→T.PassesIf∧/2∧.=¨⍴∘⍴¨data.∆Details ∆MyGitHubAPI
11-
→T.PassesIf 1=⍴⍴data.∆QuickView ∆MyGitHubAPI
12-
→T.PassesIf∧/2∧.=¨⍴∘⍴¨data.∆QuickView ∆MyGitHubAPI
9+
→T.PassesIf 1=⍴⍴data.∆Details
10+
→T.PassesIf∧/2∧.=¨⍴∘⍴¨data.∆Details
11+
→T.PassesIf 1=⍴⍴data.∆QuickView
12+
→T.PassesIf∧/2∧.=¨⍴∘⍴¨data.∆QuickView
1313

1414
R←T._OK
1515
⍝Done
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
R←Test_Issues_010(stopFlag batchFlag);⎕TRAP;data
2+
⍝ Get a an issue statistic: a matrix with all issues, their creation date and and their assigned labels
3+
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
4+
R←T._Failed
5+
6+
data←∆MyGitHubAPI.GetIssues'TestRepo'
7+
→T.PassesIf 2=⍴⍴data
8+
→T.PassesIf 4=2⊃⍴data
9+
10+
R←T._OK
11+
⍝Done
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
R←Test_Issues_011(stopFlag batchFlag);⎕TRAP;data
2+
⍝ Get a an issue statistic from a repo that has no issues at all
3+
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
4+
R←T._Failed
5+
6+
data←∆MyGitHubAPI.GetIssues'TestRepoWithoutIssues'
7+
→T.PassesIf 2=⍴⍴data
8+
→T.PassesIf 0=≢data
9+
→T.PassesIf 4=2⊃⍴data
10+
11+
R←T._OK
12+
⍝Done
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
R←Test_LabelStats_010(stopFlag batchFlag);⎕TRAP;data
2+
⍝ Get a label statistic: a matrix with all labels assigned to issues and a count
3+
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
4+
R←T._Failed
5+
6+
data←∆MyGitHubAPI.GetLabelStats'TestRepo'
7+
→T.PassesIf 2=⍴⍴data
8+
→T.PassesIf∧/⊃,/{⊃' '=1↑0⍴⍵}¨data[;1]
9+
→T.PassesIf∧/⊃,/{⊃0=1↑0⍴⍵}¨data[;2]
10+
11+
R←T._OK
12+
⍝Done
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
R←Test_LabelStats_011(stopFlag batchFlag);⎕TRAP;data
2+
⍝ Get a label statistic from a repo that has no issues aand therefore no assigned labels
3+
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
4+
R←T._Failed
5+
6+
data←∆MyGitHubAPI.GetLabelStats'TestRepoWithoutIssues'
7+
→T.PassesIf 2=⍴⍴data
8+
→T.PassesIf 0=≢data
9+
10+
R←T._OK
11+
⍝Done

TestResults/CodeCoverage.cr

832 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)