答案 0 :(得分:2)
这可能不是您正在寻找的解决方案,但此处生成的数组包含您需要的所有信息:
curl https://github.com/users/ankit8898/contributions_calendar_data
我确信你正在寻找比这更优雅的解决方案。
UPDATE 看起来这不是获取贡献者数据的最新方式。请查看StackOverflow上的其他地方以获得正确答案。
答案 1 :(得分:1)
您可以使用constructor(private breakpointObserver: BreakpointObserver, private route: ActivatedRoute) {
}
ngOnInit() {
this.route.data.map( data => data.title).subscribe(title => console.log(title));
}
网址参数从https://github.com/users/<USER>/contributions
获取svg日历,如下所示:
https://github.com/users/bertrandmartel/contributions?to=2016-12-31
您可以使用基本的xml解析器来汇总svg的所有贡献。
curl&amp;的示例2016年xmlstarlet:
to
答案 2 :(得分:1)
是的,您可以使用新的graphql API轻松完成此操作
签出资源管理器:https://developer.github.com/v4/explorer/
在那里您可以看到贡献集,它是用户的优势。您可以获得重建日历所需的所有信息。
我提供了完整的示例,资源管理器文档可以为您提供进一步的指导。
专门回答您的问题,query.user.contributionsCollection.contributionsCalendar.totalContributions
是您要寻找的东西
继续,将以下内容复制/粘贴到资源管理器中,您将看到我去年的贡献记录
query {
user(login: "qhenkart") {
email
createdAt
contributionsCollection(from: "2019-09-28T23:05:23Z", to: "2020-09-28T23:05:23Z") {
contributionCalendar {
totalContributions
weeks {
contributionDays {
weekday
date
contributionCount
color
}
}
months {
name
year
firstDay
totalWeeks
}
}
}
}
}
答案 3 :(得分:1)
要加载包含所有贡献的 svg,您可以在 html 页面中使用此代码
<img src="http://gchart.rshah.org/username" alt="Name Your Github chart">
要自定义颜色,您可以这样做
<img src="http://ghchart.rshah.org/HEXCOLORCODE/username" alt="Name Your Github chart">
答案 4 :(得分:0)
您可以使用此功能提取去年(客户)的贡献:
function getContributions(){
const svgGraph = document.getElementsByClassName('js-calendar-graph')[0];
const daysRects = svgGraph.getElementsByClassName('day');
const days = [];
for (let d of daysRects){
days.push({
date: d.getAttribute('data-date'),
count: d.getAttribute('data-count')
});
}
return days;
}
我还写了一个小节点模块,它可以提取&#39;贡献
@simonwep/github-contributions
也许这会对你有帮助(即使我已经4年到晚了)
答案 5 :(得分:0)
您可以使用github events api:
const got = require('got')
async function getEvents(username) {
const events = []
let page = 1
do {
const url = `https://api.github.com/users/${username}/events?page=${page}`
var { body } = await got(url, {
json: true
})
page++
events.push(...body)
} while(!body.length)
return events
}
(async () => {
const events = await getEvents('handtrix')
console.log('Overall Events', events.length)
console.log('PullRequests', events.filter(event => event.type === 'PullRequestEvent').length)
console.log('Forks', events.filter(event => event.type === 'ForkEvent').length)
console.log('Issues', events.filter(event => event.type === 'IssuesEvent').length)
console.log('Reviews', events.filter(event => event.type === 'PullRequestReviewEvent').length)
})()
async function getEvents(username) {
const events = []
let page = 1
do {
const url = `https://api.github.com/users/${username}/events?page=${page}`
var body = await fetch(url).then(res => res.json())
page++
events.push(...body)
} while(!body.length)
return events
}
(async () => {
const events = await getEvents('handtrix')
console.log('Overall Events', events.length)
console.log('PullRequests', events.filter(event => event.type === 'PullRequestEvent').length)
console.log('Forks', events.filter(event => event.type === 'ForkEvent').length)
console.log('Issues', events.filter(event => event.type === 'IssuesEvent').length)
console.log('Reviews', events.filter(event => event.type === 'PullRequestReviewEvent').length)
})()
答案 6 :(得分:0)
2019年的答案,请使用GitHub API V4。
首先去GitHub申请令牌:https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line。步骤7,范围仅选择read:user
URL
curl -H "Authorization: bearer token" -X POST -d '{"query":"query {\n user(login: \"MeiK2333\") {\n name\n contributionsCollection {\n contributionCalendar {\n colors\n totalContributions\n weeks {\n contributionDays {\n color\n contributionCount\n date\n weekday\n }\n firstDay\n }\n }\n }\n }\n}"}' https://api.github.com/graphql
JavaScript
async function getContributions(token, username) {
const headers = {
'Authorization': `bearer ${token}`,
}
const body = {
"query": `query {
user(login: "${username}") {
name
contributionsCollection {
contributionCalendar {
colors
totalContributions
weeks {
contributionDays {
color
contributionCount
date
weekday
}
firstDay
}
}
}
}
}`
}
const response = await fetch('https://api.github.com/graphql', { method: 'POST', body: JSON.stringify(body), headers: headers })
const data = await response.json()
return data
}
const data = await getContributions('token', 'MeiK2333')
console.log(data)
答案 7 :(得分:0)
我相信您可以在Code Climate的Velocity git分析中看到时间表中的贡献计数以及其他个人贡献者分析,您可以在此处请求访问它们:https://go.codeclimate.com/velocity-free-for-teams