mirror of
https://github.com/System-End/github-readme-stats.git
synced 2026-04-19 21:05:16 +00:00
feat: allow to customize wakatime range (#874)
* chore: allow to customize wakatime data range * docs: document wakatime range parameter docs: add wakatime section to german readme Co-authored-by: Anurag Hazra <hazru.anurag@gmail.com>
This commit is contained in:
parent
922f7165cb
commit
24e5f866c0
5 changed files with 36 additions and 5 deletions
|
|
@ -26,6 +26,7 @@ module.exports = async (req, res) => {
|
||||||
locale,
|
locale,
|
||||||
layout,
|
layout,
|
||||||
api_domain,
|
api_domain,
|
||||||
|
range,
|
||||||
border_radius,
|
border_radius,
|
||||||
} = req.query;
|
} = req.query;
|
||||||
|
|
||||||
|
|
@ -36,7 +37,7 @@ module.exports = async (req, res) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const stats = await fetchWakatimeStats({ username, api_domain });
|
const stats = await fetchWakatimeStats({ username, api_domain, range });
|
||||||
|
|
||||||
let cacheSeconds = clampValue(
|
let cacheSeconds = clampValue(
|
||||||
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
parseInt(cache_seconds || CONSTANTS.TWO_HOURS, 10),
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@
|
||||||
- [GitHub Statistiken-Karte](#github-statistiken-karte)
|
- [GitHub Statistiken-Karte](#github-statistiken-karte)
|
||||||
- [GitHub Extra Pins](#github-extra-pins)
|
- [GitHub Extra Pins](#github-extra-pins)
|
||||||
- [Top Programmiersprachen-Karte](#top-programmiersprachen-karte)
|
- [Top Programmiersprachen-Karte](#top-programmiersprachen-karte)
|
||||||
|
- [Wakatime Wochen-Statistik](#wakatime-wochen-statistik)
|
||||||
- [Erscheinungsbild/Themes](#erscheinungsbildthemes)
|
- [Erscheinungsbild/Themes](#erscheinungsbildthemes)
|
||||||
- [Anpassungen/Personalisierung](#anpassungenpersonalisierung)
|
- [Anpassungen/Personalisierung](#anpassungenpersonalisierung)
|
||||||
- [Selber betreiben](#betreibe-es-auf-deiner-eigenen-vercel-instanz)
|
- [Selber betreiben](#betreibe-es-auf-deiner-eigenen-vercel-instanz)
|
||||||
|
|
@ -166,6 +167,16 @@ Du kannst mehrere, mit Kommas separierte, Werte in der bg_color Option angeben,
|
||||||
> Sprachennamen sollten uri-escaped sein, wie hier angegeben: [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
|
> Sprachennamen sollten uri-escaped sein, wie hier angegeben: [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
|
||||||
> (z.B.: `c++` sollte zu `c%2B%2B` werden, `jupyter notebook` sollte zu `jupyter%20notebook` werden, usw.)
|
> (z.B.: `c++` sollte zu `c%2B%2B` werden, `jupyter notebook` sollte zu `jupyter%20notebook` werden, usw.)
|
||||||
|
|
||||||
|
#### Exklusive Optionen der WakaTime-Karte:
|
||||||
|
|
||||||
|
- `hide_title` - _(boolean)_
|
||||||
|
- `line_height` - Legt die Zeilenhöhe des Texts fest _(number)_
|
||||||
|
- `hide_progress` - Verbirgt die Fortschrittanzeige und Prozentzahl _(boolean)_
|
||||||
|
- `custom_title` - Legt einen benutzerdefinierten Titel fest
|
||||||
|
- `layout` - Wechselt zwischen zwei verschiedenen Layouts: `default` & `compact`
|
||||||
|
- `api_domain` - Legt eine benutzerdefinierte API Domain fest, z.B. für [Hakatime](https://github.com/mujx/hakatime) oder [Wakapi](https://github.com/muety/wakapi)
|
||||||
|
- `range` – Fragt eine eine Zeitspanne an, als die standardmäßig in WakaTime hinterlegte, z.B. `last_7_days`. Siehe [WakaTime API Dokumentation](https://wakatime.com/developers#stats).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
# GitHub Extra Pins
|
# GitHub Extra Pins
|
||||||
|
|
@ -232,6 +243,24 @@ Du kannst die `&layout=compact` Option nutzen, um das Karten Design zu ändern.
|
||||||
|
|
||||||
[](https://github.com/anuraghazra/github-readme-stats)
|
[](https://github.com/anuraghazra/github-readme-stats)
|
||||||
|
|
||||||
|
# Wakatime Wochen-Statistik
|
||||||
|
|
||||||
|
Ändere `?username=` in den eigenen [Wakatime](https://wakatime.com) Benutzernamen.
|
||||||
|
|
||||||
|
```md
|
||||||
|
[](https://github.com/anuraghazra/github-readme-stats)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Beispiel
|
||||||
|
|
||||||
|
[](https://github.com/anuraghazra/github-readme-stats)
|
||||||
|
|
||||||
|
[](https://github.com/anuraghazra/github-readme-stats)
|
||||||
|
|
||||||
|
- Kompaktes Layout
|
||||||
|
|
||||||
|
[](https://github.com/anuraghazra/github-readme-stats)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### Alle Beispiele
|
### Alle Beispiele
|
||||||
|
|
|
||||||
|
|
@ -195,7 +195,8 @@ You can provide multiple comma-separated values in bg_color option to render a g
|
||||||
- `hide_progress` - Hides the progress bar and percentage _(boolean)_
|
- `hide_progress` - Hides the progress bar and percentage _(boolean)_
|
||||||
- `custom_title` - Sets a custom title for the card
|
- `custom_title` - Sets a custom title for the card
|
||||||
- `layout` - Switch between two available layouts `default` & `compact`
|
- `layout` - Switch between two available layouts `default` & `compact`
|
||||||
- `api_domain` - Set a custom api domain for the card
|
- `api_domain` - Set a custom API domain for the card, e.g. to use services like [Hakatime](https://github.com/mujx/hakatime) or [Wakapi](https://github.com/muety/wakapi)
|
||||||
|
- `range` – Request a range different from your WakaTime default, e.g. `last_7_days`. See [WakaTime API docs](https://wakatime.com/developers#stats) for list of available options.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
|
||||||
const fetchWakatimeStats = async ({ username, api_domain }) => {
|
const fetchWakatimeStats = async ({ username, api_domain, range }) => {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get(
|
const { data } = await axios.get(
|
||||||
`https://${
|
`https://${
|
||||||
api_domain ? api_domain.replace(/[^a-z-.0-9]/gi, "") : "wakatime.com"
|
api_domain ? api_domain.replace(/[^a-z-.0-9]/gi, "") : "wakatime.com"
|
||||||
}/api/v1/users/${username}/stats?is_including_today=true`,
|
}/api/v1/users/${username}/stats/${range || ''}?is_including_today=true`,
|
||||||
);
|
);
|
||||||
|
|
||||||
return data.data;
|
return data.data;
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ describe("Wakatime fetcher", () => {
|
||||||
const username = "anuraghazra";
|
const username = "anuraghazra";
|
||||||
mock
|
mock
|
||||||
.onGet(
|
.onGet(
|
||||||
`https://wakatime.com/api/v1/users/${username}/stats?is_including_today=true`,
|
`https://wakatime.com/api/v1/users/${username}/stats/?is_including_today=true`,
|
||||||
)
|
)
|
||||||
.reply(200, wakaTimeData);
|
.reply(200, wakaTimeData);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue