-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTopContributorsRepos.jsx
More file actions
53 lines (45 loc) · 1.46 KB
/
TopContributorsRepos.jsx
File metadata and controls
53 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
Component to display the top contributors and top repositories.
This component is responsible only for rendering UI elements.
All data aggregation and processing logic is delegated to a helper
function to maintain separation of concenrs and improve reusability.
Parms:
events (Array<Object>): List of GitHub event objects passed from the parent component
*/
import { getTopContributorsAndRepos } from "../utils/getTopContributorsAndRepos";
const TOP_N = 5;
const TopContributorsRepos = ({ events = [] }) => {
/*
Retrieve pre-processes contributor and repository statistics
The helper function handles counting, sorting, and limiting results
*/
const { topContributors, topRepos } =
getTopContributorsAndRepos(events, TOP_N);
return (
<div style={{ display: "flex", gap: "30px" }}>
{/* Render list of top contributors by activity count */}
<div>
<h3>Top Contributors</h3>
<ul>
{topContributors.map((user) => (
<li key={user.name}>
{user.name} ({user.count})
</li>
))}
</ul>
</div>
{/* Render list of top repositories by activity count */}
<div>
<h3>Top Repositories</h3>
<ul>
{topRepos.map((repo) => (
<li key={repo.name}>
{repo.name} ({repo.count})
</li>
))}
</ul>
</div>
</div>
);
};
export default TopContributorsRepos;