Skip to content

Commit

Permalink
Merge branch 'navigation-bar-update' of https://github.com/uclaacm/op…
Browse files Browse the repository at this point in the history
…ensource into navigation-bar-update
  • Loading branch information
AudreyW05 committed Apr 27, 2024
2 parents 9855655 + a98de7f commit 01a664f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
Binary file added public/ucla-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 26 additions & 12 deletions util/projectRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,25 @@ import { Project, ACMCommitteeTopics, GitHubColors, GitHubRepo, GitHubIssue, GFI
export async function getProjects(): Promise<Project[]> {
const PaginatedOctokit = Octokit.plugin(paginateRest);
const octokit = new PaginatedOctokit();
const projectsResponse = await octokit.paginate('GET /orgs/{org}/repos', {
org: 'uclaacm',
const queryString = 'ucla-opensource in:topics';
const searchResponse = await octokit.paginate('GET /search/repositories', {
q: queryString,
per_page: 100,
});
}) as GitHubRepo[];

const projects = mapReposToProjects(projectsResponse);
const projects = mapReposToProjects(searchResponse);
return projects;
}

//search uclaacm org for good first issues, repos which contain gfis, and match them up
export async function getGoodFirstIssueProjects(): Promise<GFIProject[]> {
const PaginatedOctokit = Octokit.plugin(paginateRest);
const octokit = new PaginatedOctokit();
const gfiIssuesSearchQuery = 'org:uclaacm+label:"good+first+issue"+is:open';
const gfiIssuesSearchQuery = 'ucla-opensource in:topics+label:"good+first+issue"+is:open';
const gfiIssuesResponse = await octokit.paginate('GET /search/issues', {
q: gfiIssuesSearchQuery,
}) as GitHubIssue[];
const gfiReposSearchQuery = 'good-first-issues:>0+org:uclaacm';
const gfiReposSearchQuery = 'ucla-opensource in:topics+good-first-issues:>0';
const gfiReposResponse = await octokit.paginate('GET /search/repositories', {
q: gfiReposSearchQuery,
}) as GitHubRepo[];
Expand Down Expand Up @@ -59,10 +60,12 @@ function mapIssuesToProjects(issues: GitHubIssue[], repoMap: Map<string, GitHubR
while(!itVal.done){
const [repoUrl, repoIssues] = itVal.value;
const correspondingRepo = repoMap.get(repoUrl);

if(!correspondingRepo){
//console.error('Repo Map went wrong!');
// console.error('Repo Map went wrong!');
return gfis;
}

const correspondingProject = convertRepoToProject(correspondingRepo);
gfis.push({
issues: repoIssues,
Expand All @@ -83,17 +86,17 @@ function convertRepoToProject(repo: GitHubRepo): Project {
repo: repo.html_url,
lang: repo.language ?? '',
topics: repo.topics ?? [],
image: getImageFromTopics(repo.topics).image,
alt: getImageFromTopics(repo.topics).alt,
image: getImageFromRepo(repo).image,
alt: getImageFromRepo(repo).alt,
}
: {
name: repo.name,
description: repo.description ?? '',
repo: repo.html_url ?? '',
lang: repo.language ?? '',
topics: repo.topics ?? [],
image: getImageFromTopics(repo.topics).image,
alt: getImageFromTopics(repo.topics).alt,
image: getImageFromRepo(repo).image,
alt: getImageFromRepo(repo).alt,
};
}

Expand Down Expand Up @@ -169,7 +172,18 @@ function topicToImg(topic: string): ImageInfo | false {
}
}

export function getImageFromTopics(topics: string[] | undefined): ImageInfo {
export function getImageFromRepo(repo: GitHubRepo): ImageInfo {
if (repo.owner.login === 'uclaacm') {
return getACMImageFromTopics(repo.topics);
} else {
return {
image: '/ucla-logo.png',
alt: 'No logo shown',
} as ImageInfo;
}
}

function getACMImageFromTopics(topics: string[] | undefined): ImageInfo {
if (topics) {
for (const topic of topics) {
const committeeImg = topicToImg(topic);
Expand Down

0 comments on commit 01a664f

Please sign in to comment.