Skip to content

Commit

Permalink
docs:활동 - 기여 현황 대시보드 추가 (#179)
Browse files Browse the repository at this point in the history
Signed-off-by: shmruin <meme_hm@naver.com>
  • Loading branch information
shmruin authored Aug 31, 2024
1 parent c966042 commit d5efdf5
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 10 deletions.
43 changes: 34 additions & 9 deletions components/contributeInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,37 @@ const gitIssueTypeBuilder = (issueTypeInfo, cloasedAt) => {
return issueType;
};

const gitIssueBuilder = async githubId => {
const gitIssueBuilder = async (githubId, owner, repo) => {
const octokit = new Octokit({});
const response = await octokit.request('GET /repos/{owner}/{repo}/issues', {
owner: 'argoproj',
repo: 'argo-workflows',
owner,
repo,
creator: githubId,
state: 'all',
headers: { 'X-GitHub-Api-Version': '2022-11-28' },
});

const issueObj = response.data;

if (issueObj.length === 0) {
return [
{
GitHub: {
data: gitProfileBuilder({ login: githubId, avatar_url: `https://github.com/${githubId}.png`, html_url: `https://github.com/${githubId}` }),
searchLabel: githubId,
},
Type: {
data: 'None',
searchLabel: 'None',
},
Summary: {
data: 'No contributions or issues',
searchLabel: null,
},
},
];
}

return issueObj.map(issue => ({
GitHub: {
data: gitProfileBuilder(issue.user),
Expand All @@ -85,23 +104,29 @@ const gitIssueBuilder = async githubId => {
}));
};

const contributeInfoBuilder = async contributers => {
const promise = contributers.map(async contributer => await gitIssueBuilder(contributer));
const contributeInfoBuilder = async (contributers, owner, repo) => {
const promise = contributers.map(async contributer => await gitIssueBuilder(contributer, owner, repo));
const contributeInfo = await Promise.all(promise);
const flatInfo = contributeInfo.flat();
const sortedInfo = flatInfo.sort((a, b) => b.Type.searchLabel.localeCompare(a.Type.searchLabel)).sort((a, b) => a.GitHub.searchLabel.localeCompare(b.GitHub.searchLabel));
const sortedInfo = flatInfo
.sort((a, b) => {
if (a.Type.searchLabel === 'None' && b.Type.searchLabel !== 'None') return 1;
if (a.Type.searchLabel !== 'None' && b.Type.searchLabel === 'None') return -1;
return b.Type.searchLabel.localeCompare(a.Type.searchLabel);
})
.sort((a, b) => a.GitHub.searchLabel.localeCompare(b.GitHub.searchLabel));
return sortedInfo;
};

const ContributeInfo = ({ contributers = [] }) => {
const ContributeInfo = ({ contributers = [], owner = 'argoproj', repo = 'argo-workflows' }) => {
const [issueList, setIssueList] = useState([]);
const { current: contributersRef } = useRef(contributers);

const { theme } = useTheme();

useEffect(() => {
contributeInfoBuilder(contributersRef).then(data => setIssueList(data));
}, [contributersRef, contributeInfoBuilder, setIssueList, theme]);
contributeInfoBuilder(contributersRef, owner, repo).then(data => setIssueList(data));
}, [contributersRef, owner, repo, contributeInfoBuilder, setIssueList, theme]);

const contributeSummary = (
<div className="grid grid-cols-3 gap-5 mt-2 text-center text-gray-600 text-sm">
Expand Down
3 changes: 2 additions & 1 deletion pages/2024/activites/_meta.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"weeklyMeets": "주간 정기모임"
"weeklyMeets": "주간 정기모임",
"dashboard": "기여 현황판"
}
32 changes: 32 additions & 0 deletions pages/2024/activites/dashboard.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import ContributeInfo from '@components/contributeInfo';

## Argo CD 기여 현황

<ContributeInfo
contributers={[
'Jack-R-lantern',
'sunyeongchoi',
'shmruin',
'iamhansko',
'daengdaengLee',
'leehosu',
'thisishwan2',
'eugene70',
'juwon8891',
'mg5566',
'imscow11253',
'mirageoasis',
'eogns47',
'xcelxlorx',
'nueavv',
'Gaic4o',
'Junseokee',
'D0ri123',
'jcy0308',
'jjoonior',
'bianbbc87',
'SeoJimin1234',
]}
owner="argoproj"
repo="argo-cd"
/>

0 comments on commit d5efdf5

Please sign in to comment.