File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ jq . extra-cheat-sheets.json >/dev/null
14
14
readme_update () {
15
15
16
16
# Check "last_updated" field to update stars/forks in extra-cheat-sheets.json
17
- max_updates=50
17
+ max_updates=25
18
18
jq -c ' . | to_entries[]' extra-cheat-sheets.json | while read -r entry; do
19
19
# Eventual consistency, do no update to much to not hit GitHub API quota
20
20
if [ " $max_updates " -le 0 ]; then
@@ -28,13 +28,18 @@ readme_update() {
28
28
if [ -z " $last_updated " ] || [ " $( date -d " $last_updated " +%s 2> /dev/null || echo 0) " -lt " $( date -d ' 30 days ago' +%s) " ]; then
29
29
echo " Updating stats for $key "
30
30
max_updates=$(( max_updates - 1 ))
31
+ sleep 1
31
32
32
33
repo=$( echo " $value " | jq -r ' .github' )
33
34
if [ -n " $repo " ]; then
34
35
repo_api_url=" https://api.github.com/repos/$repo "
35
36
repo_data=$( curl -s " $repo_api_url " )
36
37
stars=$( echo " $repo_data " | jq -r ' .stargazers_count // 0' )
37
38
forks=$( echo " $repo_data " | jq -r ' .forks_count // 0' )
39
+ if [ $stars -eq 0 ]; then
40
+ echo " ERROR: Fail to fetch stars"
41
+ continue
42
+ fi
38
43
39
44
jq --arg key " $key " --arg stars " $stars " --arg forks " $forks " --arg date " $( date -I) " \
40
45
' .[$key] |= . + {stars: ($stars | tonumber), forks: ($forks | tonumber), last_updated: $date}' extra-cheat-sheets.json > tmp.json && mv tmp.json extra-cheat-sheets.json
You can’t perform that action at this time.
0 commit comments