Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

done with removing the deprecated apis #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 5 additions & 68 deletions src/main/java/com/openelements/issues/ApiEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,81 +26,18 @@ public ApiEndpoint(@NonNull final GitHubCache issueCache) {
this.issueCache = Objects.requireNonNull(issueCache, "issueCache must not be null");
}

@Deprecated(forRemoval = true)
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) {
}

/**
* @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
* @return Set of good first issues
*/
@Deprecated(forRemoval = true)
@GetMapping("/api/hacktoberfest-issues")
public Set<OldIssueResponse> getHacktoberfestIssuesOld() {
log.warn("DEPRECATED API CALLED: Getting Hacktoberfest issues");
return issueCache.getIssues(LabelConstants.HACKTOBERFEST_LABEL).stream()
.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()))
.collect(Collectors.toUnmodifiableSet());
}

/**
* @deprecated Use {@link #getContributors()} instead
* @return
*/
@Deprecated(forRemoval = true)
@GetMapping("/api/contributors")
public Set<Contributor> getContributorsOld() {
log.warn("DEPRECATED API CALLED: Getting Contributors");
return getContributors();
}

/**
* @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
* @return Set of good first issues
*/
@Deprecated(forRemoval = true)
@GetMapping("/api/good-first-issues")
public Set<OldIssueResponse> getGoodFirstIssuesOld() {
log.info("Getting good first issues");
return issueCache.getIssues(LabelConstants.GOOD_FIRST_ISSUE_LABEL).stream()
.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()))
.collect(Collectors.toUnmodifiableSet());
}

/**
* @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
* @return Set of good first issues
*/
@Deprecated(forRemoval = true)
@GetMapping("/api/good-first-issue-candidates")
public Set<OldIssueResponse> getGoodFirstIssuesCandidatesOld() {
log.info("Getting good first issue candidates");
return issueCache.getIssues(LabelConstants.GOOD_FIRST_ISSUE_CANDIDATE_LABEL).stream()
.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()))
.collect(Collectors.toUnmodifiableSet());
}

/**
* @deprecated Use {@link #getIssues(Boolean, Boolean, Set, Set, Set)} instead
* @return Set of good first issues
*/
@Deprecated(forRemoval = true)
@GetMapping("/api/help-wanted-issues")
public Set<OldIssueResponse> getHelpWantedIssuesOld() {
log.info("Getting help wanted issues");
return issueCache.getIssues(LabelConstants.HELP_WANTED_LABEL).stream()
.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()))
.collect(Collectors.toUnmodifiableSet());
}

@GetMapping("/api/v2/contributors")
public Set<Contributor> getContributors() {
log.info("Getting contributors");
return issueCache.getContributors();
}

@GetMapping("/api/v2/issues")
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) {
public Set<Issue> getIssues(@PathVariable(name = "isAssigned", required = false) Boolean isAssigned,
@PathVariable(name = "isClosed",required = false) Boolean isClosed,
@PathVariable(name = "filteredLabels",required = false) Set<String> filteredLabels,
@PathVariable(name = "excludedLabels",required = false) Set<String> excludedLabels,
@PathVariable(name = "filteredLanguages",required = false) Set<String> filteredLanguages) {
log.info("Getting good first issues");
return issueCache.getAllIssues().stream()
.filter(issue -> isAssigned == null || issue.isAssigned() == isAssigned)
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/contributors.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h1 class="text-3xl font-bold mb-6 text-center">Contributors</h1>
<script>

async function fetchContributors() {
const response = await fetch('/api/contributors');
const response = await fetch('/api/v2/contributors');
const contributors = await response.json();
return contributors;
}
Expand Down
30 changes: 14 additions & 16 deletions src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ <h1 class="text-3xl font-bold mb-6 text-center">Good First Issues</h1>
function populateLanguageFilter(issues) {
var uniqueLanguages = new Set();
issues.forEach(issue => {
issue.languageTags.forEach(language => uniqueLanguages.add(language));
issue.repository.languages
.forEach(language => uniqueLanguages.add(language));
});
const labelFilter = document.getElementById('language-filter');
labelFilter.innerHTML = '<option value="">All Languages</option>'; // Reset options
Expand All @@ -50,7 +51,7 @@ <h1 class="text-3xl font-bold mb-6 text-center">Good First Issues</h1>


async function fetchIssues() {
const response = await fetch('/api/good-first-issues');
const response = await fetch('/api/v2/issues');
const issues = await response.json();
return issues;
}
Expand All @@ -59,15 +60,13 @@ <h1 class="text-3xl font-bold mb-6 text-center">Good First Issues</h1>
function renderIssues(issues) {
const list = document.getElementById('issues-list');
list.innerHTML = ''; // Clear any existing rows

issues.sort((a, b) => {
const orgA = a.org.toLowerCase();
const orgB = b.org.toLowerCase();
const repoA = a.repo.toLowerCase();
const repoB = b.repo.toLowerCase();
const identifierA = a.identifier.toLowerCase();
const identifierB = b.identifier.toLowerCase();

const orgA = a.repository.org.toLowerCase();
const orgB = b.repository.org.toLowerCase();
const repoA = a.repository.name.toLowerCase();
const repoB = b.repository.name.toLowerCase();
const identifierA = a.identifier;
const identifierB = b.identifier;
// Compare by organization
if (orgA < orgB) return -1;
if (orgA > orgB) return 1;
Expand Down Expand Up @@ -97,15 +96,15 @@ <h1 class="text-3xl font-bold mb-6 text-center">Good First Issues</h1>

listItem.innerHTML = `
<div class="flex min-w-0 gap-x-4">
<img class="h-12 w-12 flex-none rounded-full bg-gray-50" src="${issue.imageUrl}" alt="">
<img class="h-12 w-12 flex-none rounded-full bg-gray-50" src="${issue.repository.imageUrl}" alt="">
<div class="min-w-0 flex-auto">
<p class="text-sm font-semibold leading-6 text-gray-900">${issue.title}</p>
<p class="mt-1 truncate text-xs leading-5 text-gray-500"><a href="https://github.com/${issue.org}/${issue.repo}" class="text-blue-600 hover:underline" target="_blank">${issue.repo}</a></p>
<p class="mt-1 truncate text-xs leading-5 text-gray-500"><a href="https://github.com/${issue.repository.org}/${issue.repository.name}" class="text-blue-600 hover:underline" target="_blank">${issue.repository.name}</a></p>
</div>
</div>
<div class="hidden shrink-0 sm:flex sm:flex-col sm:items-end">
<p class="text-sm leading-6 text-gray-900">
${issue.languageTags.map(tag => `
${issue.repository.languages.map(tag => `
<span class="inline-flex items-center rounded-full bg-green-50 px-2 py-1 text-xs font-medium text-green-700 ring-1 ring-inset ring-green-600/20">${tag}</span>
`).join('')}
</p>
Expand All @@ -129,15 +128,14 @@ <h1 class="text-3xl font-bold mb-6 text-center">Good First Issues</h1>
loadingElement.classList.add('hidden');
tableContainer.classList.remove('hidden');
} catch (error) {
loadingElement.textContent = 'Failed to load data. Please try again later.';
loadingElement.textContent = 'Failed to load data. Please try again later.' + error;
}

// Event listener to filter issues by selected label
document.getElementById('language-filter').addEventListener('change', function() {
const selectedLabel = this.value;
const filteredIssues = selectedLabel
? issues.filter(issue => issue.languageTags.some(label => {
console.log('comparing' + label + ' with ' + selectedLabel);
? issues.filter(issue => issue.repository.languages.some(label => {
return label === selectedLabel;
}))
: issues;
Expand Down
Loading