Skip to content

Commit a69ce7a

Browse files
authored
Merge pull request #4 from Fiveneves/fiveneves
add community openrank api and feature container
2 parents 957347a + 0a7b9d0 commit a69ce7a

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/api/community.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import request from '../helpers/request';
2+
import { ErrorCode, OSS_XLAB_ENDPOINT } from '../constant';
3+
4+
export const getMetricByDate = async (repoName: string, date: string) => {
5+
try {
6+
return await request(
7+
`${OSS_XLAB_ENDPOINT}/open_digger/github/${repoName}/project_openrank_detail/${date}.json`
8+
);
9+
} catch (error) {
10+
// the catched error being "404" means the metric file is not available so return a null
11+
if (error === ErrorCode.NOT_FOUND) {
12+
return null;
13+
} else {
14+
// other errors should be throwed
15+
throw error;
16+
}
17+
}
18+
};
19+
20+
export const getOpenrank = async (repo: string, date: string) => {
21+
return getMetricByDate(repo, date);
22+
};

src/pages/ContentScripts/features/perceptor-layout/view.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const View = (): JSX.Element => {
55
<>
66
<div id="hypercrx-perceptor-slot-repo-activity-racing-bar" />
77
<div id="hypercrx-perceptor-slot-repo-networks" />
8+
<div id="hypercrx-perceptor-slot-community-openrank-racing-bar" />
9+
<div id="hypercrx-perceptor-slot-community-openrank-network" />
810
</>
911
);
1012
};

0 commit comments

Comments
 (0)