@@ -17,35 +17,43 @@ function alfredMatcher(str) {
17
17
function run ( ) {
18
18
const resultsNumber = 50 ; // api allows up to 100
19
19
const username = $ . getenv ( "github_username" ) ;
20
- const apiURL = `https://api.github.com/search/issues?q=involves:${ username } &per_page=${ resultsNumber } ` ;
20
+
21
+ // DOCS https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#list-issues-assigned-to-the-authenticated-user--parameters
22
+ const apiURL = `https://api.github.com/search/issues?q=involves:${ username } &sort=updated&per_page=${ resultsNumber } ` ;
21
23
22
24
const issues = JSON . parse ( app . doShellScript ( `curl -sL "${ apiURL } "` ) ) . items . map (
23
25
( /** @type {GithubIssue } */ item ) => {
24
26
const issueAuthor = item . user . login ;
25
- const authoredByMe = issueAuthor === username ;
26
-
27
27
const isPR = Boolean ( item . pull_request ) ;
28
28
const merged = Boolean ( item . pull_request ?. merged_at ) ;
29
29
const title = item . title ;
30
30
const repo = ( item . repository_url . match ( / [ ^ / ] + $ / ) || "" ) [ 0 ] ;
31
31
const comments = item . comments > 0 ? "π¬ " + item . comments . toString ( ) : "" ;
32
+ const open = item . state === "open" ;
33
+ const closed = item . state === "closed" ;
34
+ const reason = item . state_reason ;
35
+ const labels = item . labels . map ( ( label ) => `[${ label . name } ]` ) . join ( " " ) ;
36
+
37
+ const subtitle = [ `#${ item . number } ` , repo , comments . toString ( ) , labels ]
38
+ . filter ( Boolean )
39
+ . join ( " " ) ;
32
40
33
- let icon = authoredByMe ? "π© " : "" ;
34
- if ( item . state === "open" && isPR ) icon += "π© ";
35
- else if ( item . state === "closed" && isPR && merged ) icon += "πͺ " ;
36
- else if ( item . state === " closed" && isPR && ! merged ) icon += "π₯ " ;
37
- else if ( item . state === "closed" && ! isPR ) icon += "π£ " ;
38
- else if ( item . state === " open" && ! isPR ) icon += "π’ " ;
39
- if ( title . toLowerCase ( ) . includes ( "request" ) || title . includes ( "FR" ) ) icon += "π " ;
40
- if ( title . toLowerCase ( ) . includes ( "bug" ) ) icon += "πͺ² " ;
41
+ // icon
42
+ let icon = issueAuthor === username ? "βοΈ " : " ";
43
+ if ( open && isPR ) icon += "π© " ;
44
+ else if ( closed && isPR && merged ) icon += "πͺ " ;
45
+ else if ( closed && isPR && ! merged ) icon += "π₯ " ;
46
+ else if ( open && ! isPR ) icon += "π’ " ;
47
+ else if ( closed && reason === "not_planned" ) icon += "βͺ " ;
48
+ else if ( closed && reason === "completed" ) icon += "π£ " ;
41
49
42
50
let matcher = alfredMatcher ( item . title ) + " " + alfredMatcher ( repo ) + " " + item . state ;
43
51
if ( isPR ) matcher += " pr" ;
44
52
else matcher += " issue" ;
45
53
46
54
return {
47
55
title : icon + title ,
48
- subtitle : `# ${ item . number } ${ repo } ${ comments } ` ,
56
+ subtitle : subtitle ,
49
57
match : matcher ,
50
58
arg : item . html_url ,
51
59
quicklookurl : item . html_url ,
0 commit comments