Closed T0nd0Tara closed 1 day ago
I will consider your suggestion. Thank you.
If you'd like I might be able to it myself in the near future. Using sed
Parsing contributions directly from https://github.com/users/T0nd0Tara/contributions may not be the best approach; using a third-party API might be better. Additionally, not using a token to fetch contributions could become a configurable option, with the default still relying on the token. The official API remains more reliable.
I've found this third party API https://github.com/grubersjoe/github-contributions-api. That can provide contributions based on a range and in different formats.
If it's ok with you I'll start working to migrating this api, based on a config flag ofcourse
user = "Kurama622",
git_contributions = {
start_week = 1,
end_week = 53,
empty_char = " ",
full_char = { "", "", "", "", "" },
fake_contributions = nil,
non_official_api_cmd = [[curl -s https://github-contributions-api.jogruber.de/v4/%s | jq '.contributions' | jq --arg start $(date -d "1 year ago" +%%Y-%%m-%%d) --arg end $(date +%%Y-%%m-%%d) '.[] | select((.date >= $start) and (.date <= $end))' | jq -s 'sort_by(.date) | map(.count) | . as $array | reduce range(0; length; 7) as $i ({}; . + {($i/7+1 | tostring): $array[$i:$i+7]})']],
},
you can fetch contributions without github tokens by non_official_api_cmd, this is an example
user = "Kurama622", git_contributions = { start_week = 1, end_week = 53, empty_char = " ", full_char = { "", "", "", "", "" }, fake_contributions = nil, non_official_api_cmd = [[curl -s https://github-contributions-api.jogruber.de/v4/%s | jq '.contributions' | jq --arg start $(date -d "1 year ago" +%%Y-%%m-%%d) --arg end $(date +%%Y-%%m-%%d) '.[] | select((.date >= $start) and (.date <= $end))' | jq -s 'sort_by(.date) | map(.count) | . as $array | reduce range(0; length; 7) as $i ({}; . + {($i/7+1 | tostring): $array[$i:$i+7]})']], },
你可以通过 non_official_api_cmd 获取没有 github token 的贡献,这是一个示例
But it's a bit slow, maybe my shell command is not efficient enough.
$(date -d "1 year ago" +%%Y-%%m-%%d)
:
Different from the date format in the shell, I used the %%Y format because Lua needs to escape % .
You can generally implement your shell commands, maybe yours is more efficient.
Thank you for the feature, and even more so for the command!
For the future users looking at this issue, you can slightly speed up the command by specifying only the years you want. ie.
curl -s "https://github-contributions-api.jogruber.de/v4/%s?y=$(date -d "1 year ago" +%%Y)&y=$(date +%%Y)" | jq '.contributions' | jq --arg start $(date -d "1 year ago" +%%Y-%%m-%%d) --arg end $(date +%%Y-%%m-%%d) '.[] | select((.date >= $start) and (.date <= $end))' | jq -s 'sort_by(.date) | map(.count) | . as $array | reduce range(0; length; 7) as $i ({}; . + {($i/7+1 | tostring): $array[$i:$i+7]})'
and even more by using a jq
alternative
I've tried to debug this plugin as I saw it didn't work on my machine.
and I noticed It requires the github authorization token to get the data through the graphql api. I (and I believe many more) don't want to save locally tokens if we don't need to. I think a better solution would be to get the contributions from
https://github.com/users/T0nd0Tara/contributions
url (that have all the necessary data).And then parse it into the format the plugin need