3
3
import com .openelements .issues .data .Contributor ;
4
4
import com .openelements .issues .data .Issue ;
5
5
import com .openelements .issues .services .GitHubCache ;
6
+ import java .util .List ;
6
7
import java .util .Objects ;
7
8
import java .util .Set ;
8
9
import java .util .stream .Collectors ;
@@ -25,46 +26,88 @@ public ApiEndpoint(@NonNull final GitHubCache issueCache) {
25
26
this .issueCache = Objects .requireNonNull (issueCache , "issueCache must not be null" );
26
27
}
27
28
29
+ @ Deprecated (forRemoval = true )
30
+ private record OldIssueResponse (@ NonNull String title , @ NonNull String link , @ NonNull String org , @ NonNull String repo , @ NonNull String imageUrl , @ NonNull String identifier , boolean isAssigned , boolean isClosed , @ NonNull List <String > labels , @ NonNull List <String > languageTags ) {
31
+ }
32
+
33
+ /**
34
+ * @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
35
+ * @return Set of good first issues
36
+ */
37
+ @ Deprecated (forRemoval = true )
38
+ @ GetMapping ("/api/hacktoberfest-issues" )
39
+ public Set <OldIssueResponse > getHacktoberfestIssuesOld () {
40
+ log .warn ("DEPRECATED API CALLED: Getting Hacktoberfest issues" );
41
+ return issueCache .getIssues (LabelConstants .HACKTOBERFEST_LABEL ).stream ()
42
+ .map (issue -> new OldIssueResponse (issue .title (), issue .link (), issue .repository ().org (), issue .repository ().name (), issue .repository ().imageUrl (), issue .identifier (), issue .isAssigned (), issue .isClosed (), issue .labels (), issue .repository ().languages ()))
43
+ .collect (Collectors .toUnmodifiableSet ());
44
+ }
45
+
46
+ /**
47
+ * @deprecated Use {@link #getContributors()} instead
48
+ * @return
49
+ */
50
+ @ Deprecated (forRemoval = true )
51
+ @ GetMapping ("/api/contributors" )
52
+ public Set <Contributor > getContributorsOld () {
53
+ log .warn ("DEPRECATED API CALLED: Getting Contributors" );
54
+ return getContributors ();
55
+ }
56
+
57
+ /**
58
+ * @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
59
+ * @return Set of good first issues
60
+ */
61
+ @ Deprecated (forRemoval = true )
28
62
@ GetMapping ("/api/good-first-issues" )
29
- public Set <Issue > getGoodFirstIssues () {
63
+ public Set <OldIssueResponse > getGoodFirstIssuesOld () {
30
64
log .info ("Getting good first issues" );
31
- return issueCache .getIssues (LabelConstants .GOOD_FIRST_ISSUE_LABEL );
65
+ return issueCache .getIssues (LabelConstants .GOOD_FIRST_ISSUE_LABEL ).stream ()
66
+ .map (issue -> new OldIssueResponse (issue .title (), issue .link (), issue .repository ().org (), issue .repository ().name (), issue .repository ().imageUrl (), issue .identifier (), issue .isAssigned (), issue .isClosed (), issue .labels (), issue .repository ().languages ()))
67
+ .collect (Collectors .toUnmodifiableSet ());
32
68
}
33
69
70
+ /**
71
+ * @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
72
+ * @return Set of good first issues
73
+ */
74
+ @ Deprecated (forRemoval = true )
34
75
@ GetMapping ("/api/good-first-issue-candidates" )
35
- public Set <Issue > getGoodFirstIssuesCandidates () {
76
+ public Set <OldIssueResponse > getGoodFirstIssuesCandidatesOld () {
36
77
log .info ("Getting good first issue candidates" );
37
- return issueCache .getIssues (LabelConstants .GOOD_FIRST_ISSUE_CANDIDATE_LABEL );
38
- }
39
-
40
- @ GetMapping ("/api/hacktoberfest-issues" )
41
- public Set <Issue > getHacktoberfestIssues () {
42
- log .info ("Getting Hacktoberfest issues" );
43
- return issueCache .getIssues (LabelConstants .HACKTOBERFEST_LABEL );
78
+ return issueCache .getIssues (LabelConstants .GOOD_FIRST_ISSUE_CANDIDATE_LABEL ).stream ()
79
+ .map (issue -> new OldIssueResponse (issue .title (), issue .link (), issue .repository ().org (), issue .repository ().name (), issue .repository ().imageUrl (), issue .identifier (), issue .isAssigned (), issue .isClosed (), issue .labels (), issue .repository ().languages ()))
80
+ .collect (Collectors .toUnmodifiableSet ());
44
81
}
45
82
83
+ /**
84
+ * @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
85
+ * @return Set of good first issues
86
+ */
87
+ @ Deprecated (forRemoval = true )
46
88
@ GetMapping ("/api/help-wanted-issues" )
47
- public Set <Issue > getHelpWantedIssues () {
89
+ public Set <OldIssueResponse > getHelpWantedIssuesOld () {
48
90
log .info ("Getting help wanted issues" );
49
- return issueCache .getIssues (LabelConstants .HELP_WANTED_LABEL );
91
+ return issueCache .getIssues (LabelConstants .HELP_WANTED_LABEL ).stream ()
92
+ .map (issue -> new OldIssueResponse (issue .title (), issue .link (), issue .repository ().org (), issue .repository ().name (), issue .repository ().imageUrl (), issue .identifier (), issue .isAssigned (), issue .isClosed (), issue .labels (), issue .repository ().languages ()))
93
+ .collect (Collectors .toUnmodifiableSet ());
50
94
}
51
95
52
- @ GetMapping ("/api/contributors" )
96
+ @ GetMapping ("/api/v2/ contributors" )
53
97
public Set <Contributor > getContributors () {
54
98
log .info ("Getting contributors" );
55
99
return issueCache .getContributors ();
56
100
}
57
101
58
- @ GetMapping ("/api/issues" )
59
- public Set <Issue > getGoodFirstIssues (@ PathVariable (required = false ) Boolean isAssigned , @ PathVariable (required = false ) Boolean isClosed , @ PathVariable (required = false ) Set <String > filteredLabels , @ PathVariable (required = false ) Set <String > excludedLabels , @ PathVariable (required = false ) Set <String > filteredLanguages ) {
102
+ @ GetMapping ("/api/v2/ issues" )
103
+ public Set <Issue > getIssues (@ PathVariable (required = false ) Boolean isAssigned , @ PathVariable (required = false ) Boolean isClosed , @ PathVariable (required = false ) Set <String > filteredLabels , @ PathVariable (required = false ) Set <String > excludedLabels , @ PathVariable (required = false ) Set <String > filteredLanguages ) {
60
104
log .info ("Getting good first issues" );
61
105
return issueCache .getAllIssues ().stream ()
62
106
.filter (issue -> isAssigned == null || issue .isAssigned () == isAssigned )
63
107
.filter (issue -> isClosed == null || issue .isClosed () == isClosed )
64
108
.filter (issue -> filteredLabels == null || issue .labels ().containsAll (filteredLabels ))
65
109
.filter (issue -> excludedLabels == null || issue .labels ().stream ().noneMatch (excludedLabels ::contains ))
66
- .filter (issue -> filteredLanguages == null || issue .languageTags ().containsAll (filteredLanguages ))
110
+ .filter (issue -> filteredLanguages == null || issue .repository (). languages ().containsAll (filteredLanguages ))
67
111
.collect (Collectors .toUnmodifiableSet ());
68
112
}
69
-
70
113
}
0 commit comments