Skip to content

Commit

Permalink
feat(activities): raise github commit counter days
Browse files Browse the repository at this point in the history
  • Loading branch information
Lino authored and FFHener committed Apr 2, 2024
1 parent 0b6860d commit f6edb46
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions layouts/partials/activities-github.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{{ $ACCESS_TOKEN := getenv "HUGO_GITHUB_ACCESS_TOKEN" }}

{{/* Defaults for development without matrix access token. */}}
{{/* Defaults for development without github access token. */}}
{{ $github_activity := dict "repo_count" 42 "top_repos" (slice "foo" "bar") "commit_count" 161 }}

{{ if $ACCESS_TOKEN }}
Expand Down Expand Up @@ -43,15 +43,15 @@
{{ $top_repos = $top_repos | append $repo.name }}
{{ end }}

{{/* Number of commits of the last seven days in all the repos.
{{/* Number of commits of the last 30 days in all the repos.
A maximum of 10 pages with up to 100 commits each are checked.
If more than 1000 commits exist for a repo an error is thrown. */}}
{{ $past_seven_days_date := now.AddDate 0 0 -7 }}
{{ $past_seven_days := $past_seven_days_date.Format "2006-01-02T15:04:05Z" }}
{{ $past_thirty_days_date := now.AddDate 0 0 -30 }}
{{ $past_thirty_days := $past_thirty_days_date.Format "2006-01-02T15:04:05Z" }}
{{ $commit_count := 0 }}
{{ range $repo := $repo_list }}
{{ range $page := (seq 10) }}
{{ $commit_url := printf "https://api.github.com/repos/freifunk-berlin/%s/commits?per_page=100&since=%s&page=%d" $repo.name $past_seven_days $page }}
{{ $commit_url := printf "https://api.github.com/repos/freifunk-berlin/%s/commits?per_page=100&since=%s&page=%d" $repo.name $past_thirty_days $page }}
{{ $commit_json := getJSON $commit_url $headers }}
{{ $commit_count = add $commit_count (len $commit_json) }}
{{ if lt (len $commit_json) 100 }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/shortcodes/activities-github.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

{{ if eq .Site.Language.Lang "de" }}
Zur Versionsverwaltung der Software nutzen wir <a href="https://github.com/freifunk-berlin/">Github</a>.
Dort gab es in den letzten sieben Tagen <b>{{ $github_activity.commit_count }} (commits)</b> Änderungen am Code.
Dort gab es in den letzten 30 Tagen <b>{{ $github_activity.commit_count }} (commits)</b> Änderungen am Code.
Auf der Platform werden insgesamt <b>{{ $github_activity.repo_count }} (repositories)</b> Projekte verwaltet.
Die aktivsten sind derzeit:
{{ else if eq .Site.Language.Lang "en" }}
We use <a href="https://github.com/freifunk-berlin/">Github</a> for version control of the software.
There have been <b>{{ $github_activity.commit_count }} (commits)</b> changes to the code in the last seven days.
There have been <b>{{ $github_activity.commit_count }} (commits)</b> changes to the code in the last 30 days.
A total of <b>{{ $github_activity.repo_count }} (repositories)</b> projects are managed on the platform.
The most active are currently:
{{ end }}
Expand Down

0 comments on commit f6edb46

Please sign in to comment.