Skip to content

Commit 522762a

Browse files
committed
Merge branch 'master' into reorganize-readme
2 parents 49b8840 + 0efb982 commit 522762a

22 files changed

+272
-97
lines changed

api/index.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as dotenv from "dotenv";
21
import { renderStatsCard } from "../src/cards/stats-card.js";
32
import { blacklist } from "../src/common/blacklist.js";
43
import {
@@ -11,8 +10,6 @@ import {
1110
import { fetchStats } from "../src/fetchers/stats-fetcher.js";
1211
import { isLocaleAvailable } from "../src/translations.js";
1312

14-
dotenv.config();
15-
1613
export default async (req, res) => {
1714
const {
1815
username,
@@ -26,6 +23,7 @@ export default async (req, res) => {
2623
include_all_commits,
2724
line_height,
2825
title_color,
26+
ring_color,
2927
icon_color,
3028
text_color,
3129
text_bold,
@@ -63,7 +61,12 @@ export default async (req, res) => {
6361
CONSTANTS.ONE_DAY,
6462
);
6563

66-
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
64+
res.setHeader(
65+
"Cache-Control",
66+
`max-age=${
67+
cacheSeconds / 2
68+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
69+
);
6770

6871
return res.send(
6972
renderStatsCard(stats, {
@@ -76,6 +79,7 @@ export default async (req, res) => {
7679
include_all_commits: parseBoolean(include_all_commits),
7780
line_height,
7881
title_color,
82+
ring_color,
7983
icon_color,
8084
text_color,
8185
text_bold: parseBoolean(text_bold),

api/pin.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ export default async (req, res) => {
5858
cacheSeconds = CONSTANTS.FOUR_HOURS;
5959
}
6060

61-
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
61+
res.setHeader(
62+
"Cache-Control",
63+
`max-age=${
64+
cacheSeconds / 2
65+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
66+
);
6267

6368
return res.send(
6469
renderRepoCard(repoData, {

api/top-langs.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as dotenv from "dotenv";
21
import { renderTopLanguages } from "../src/cards/top-languages-card.js";
32
import { blacklist } from "../src/common/blacklist.js";
43
import {
@@ -11,8 +10,6 @@ import {
1110
import { fetchTopLanguages } from "../src/fetchers/top-languages-fetcher.js";
1211
import { isLocaleAvailable } from "../src/translations.js";
1312

14-
dotenv.config();
15-
1613
export default async (req, res) => {
1714
const {
1815
username,
@@ -55,7 +52,12 @@ export default async (req, res) => {
5552
CONSTANTS.ONE_DAY,
5653
);
5754

58-
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
55+
res.setHeader(
56+
"Cache-Control",
57+
`max-age=${
58+
cacheSeconds / 2
59+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
60+
);
5961

6062
return res.send(
6163
renderTopLanguages(topLangs, {

api/wakatime.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as dotenv from "dotenv";
21
import { renderWakatimeCard } from "../src/cards/wakatime-card.js";
32
import {
43
clampValue,
@@ -10,8 +9,6 @@ import {
109
import { fetchWakatimeStats } from "../src/fetchers/wakatime-fetcher.js";
1110
import { isLocaleAvailable } from "../src/translations.js";
1211

13-
dotenv.config();
14-
1512
export default async (req, res) => {
1613
const {
1714
username,
@@ -55,7 +52,12 @@ export default async (req, res) => {
5552
cacheSeconds = CONSTANTS.FOUR_HOURS;
5653
}
5754

58-
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
55+
res.setHeader(
56+
"Cache-Control",
57+
`max-age=${
58+
cacheSeconds / 2
59+
}, s-maxage=${cacheSeconds}, stale-while-revalidate=${CONSTANTS.ONE_DAY}`,
60+
);
5961

6062
return res.send(
6163
renderWakatimeCard(stats, {

docs/readme_pt-BR.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
<a href="/docs/readme_nl.md">Nederlands</a>
5454
.
5555
<a href="/docs/readme_np.md">नेपाली</a>
56+
.
57+
<a href="/docs/readme_tr.md">Türkçe</a>
5658
</p>
5759
</p>
5860
<p align="center">Gostou do projeto? Por favor considere <a href="https://www.paypal.me/anuraghazra">fazer uma doação</a> para ajudar a melhorá-lo!
@@ -142,7 +144,7 @@ Personalize a aparência do seu `Stats Card` ou `Repo Card` da maneira que desej
142144
- `cache_seconds` - Defina o cabeçalho do cache manualmente _(min: 1800, max: 86400)_
143145
- `locale` - defina o idioma no cartão _(por exemplo. cn, de, es, etc.)_
144146

145-
> Nota sobre o cache: Cartões de repositório tem um cache padrão de 30 minutos (1800 segundos), se o número a contagem de forks e contagem de estrelas é menor que 1 mil o padrão é 2 horas (7200). Note também que o cache é limitado a um mínimo de 30 minutos e um máximo de 24 horas.
147+
> Nota sobre o cache: Cartões de repositório tem um cache padrão de 30 minutos (1800 segundos), se o número a contagem de forks e contagem de estrelas é menor que 1 mil o padrão é 2 horas (7200 segundos). Note também que o cache é limitado a um mínimo de 30 minutos e um máximo de 24 horas.
146148
147149
#### Opções exclusivas do cartão de estatísticas:
148150

@@ -167,7 +169,7 @@ Personalize a aparência do seu `Stats Card` ou `Repo Card` da maneira que desej
167169

168170
> :warning: **Importante:**
169171
> Nomes de linguagens devem ser uma sequência escapada de URI, como específicado em [Codificação por cento](https://pt.wikipedia.org/wiki/Codificação_por_cento)
170-
> (Isso é: `c++` deve se tornar `c%2B%2B`, `jupyter notebook` deve se tornar `jupyter%20notebook`, etc.)
172+
> (Ou seja: `c++` deve se tornar `c%2B%2B`, `jupyter notebook` deve se tornar `jupyter%20notebook`, etc.)
171173
172174
---
173175

scripts/close-stale-theme-prs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { RequestError } from "@octokit/request-error";
1010
import { getGithubToken, getRepoInfo } from "./helpers.js";
1111

1212
const CLOSING_COMMENT = `
13-
\rThis PR has been automatically closed due to inactivity. Please feel free to reopen it if you need to continue working on it.\
13+
\rThis theme PR has been automatically closed due to inactivity. Please reopen it if you want to continue working on it.\
1414
\rThank you for your contributions.
1515
`;
1616
const REVIEWER = "github-actions[bot]";

src/calculateRank.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* @param {number} to The value to calculate the probability for.
1010
* @returns {number} Probability.
1111
*/
12-
function normalcdf(mean, sigma, to) {
12+
const normalcdf = (mean, sigma, to) => {
1313
var z = (to - mean) / Math.sqrt(2 * sigma * sigma);
1414
var t = 1 / (1 + 0.3275911 * Math.abs(z));
1515
var a1 = 0.254829592;
@@ -24,7 +24,7 @@ function normalcdf(mean, sigma, to) {
2424
sign = -1;
2525
}
2626
return (1 / 2) * (1 + sign * erf);
27-
}
27+
};
2828

2929
/**
3030
* Calculates the users rank.
@@ -38,15 +38,15 @@ function normalcdf(mean, sigma, to) {
3838
* @param {number} stargazers The number of stars.
3939
* @returns {{level: string, score: number}}} The users rank.
4040
*/
41-
function calculateRank({
41+
const calculateRank = ({
4242
totalRepos,
4343
totalCommits,
4444
contributions,
4545
followers,
4646
prs,
4747
issues,
4848
stargazers,
49-
}) {
49+
}) => {
5050
const COMMITS_OFFSET = 1.65;
5151
const CONTRIBS_OFFSET = 1.65;
5252
const ISSUES_OFFSET = 1;
@@ -70,7 +70,11 @@ function calculateRank({
7070
const RANK_B_VALUE = 100;
7171

7272
const TOTAL_VALUES =
73-
RANK_S_VALUE + RANK_A2_VALUE + RANK_A3_VALUE + RANK_B_VALUE;
73+
RANK_S_VALUE +
74+
RANK_DOUBLE_A_VALUE +
75+
RANK_A2_VALUE +
76+
RANK_A3_VALUE +
77+
RANK_B_VALUE;
7478

7579
// prettier-ignore
7680
const score = (
@@ -94,7 +98,7 @@ function calculateRank({
9498
})();
9599

96100
return { level, score: normalizedScore };
97-
}
101+
};
98102

99103
export { calculateRank };
100104
export default calculateRank;

src/cards/stats-card.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
8989
include_all_commits = false,
9090
line_height = 25,
9191
title_color,
92+
ring_color,
9293
icon_color,
9394
text_color,
9495
text_bold = true,
@@ -104,13 +105,14 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
104105
const lheight = parseInt(String(line_height), 10);
105106

106107
// returns theme based colors with proper overrides and defaults
107-
const { titleColor, textColor, iconColor, bgColor, borderColor } =
108+
const { titleColor, iconColor, textColor, bgColor, borderColor, ringColor } =
108109
getCardColors({
109110
title_color,
110-
icon_color,
111111
text_color,
112+
icon_color,
112113
bg_color,
113114
border_color,
115+
ring_color,
114116
theme,
115117
});
116118

@@ -201,6 +203,7 @@ const renderStatsCard = (stats = {}, options = { hide: [] }) => {
201203
const progress = 100 - rank.score;
202204
const cssStyles = getStyles({
203205
titleColor,
206+
ringColor,
204207
textColor,
205208
iconColor,
206209
show_icons,

src/common/retryer.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { CustomError, logger } from "./utils.js";
22

3+
// Script variables.
4+
const PATs = Object.keys(process.env).filter((key) =>
5+
/PAT_\d*$/.exec(key),
6+
).length;
7+
const RETRIES = PATs ? PATs : 7;
8+
39
/**
410
* Try to execute the fetcher function until it succeeds or the max number of retries is reached.
511
*
@@ -10,7 +16,7 @@ import { CustomError, logger } from "./utils.js";
1016
* @returns Promise<retryer>
1117
*/
1218
const retryer = async (fetcher, variables, retries = 0) => {
13-
if (retries > 7) {
19+
if (retries > RETRIES) {
1420
throw new CustomError("Maximum retries exceeded", CustomError.MAX_RETRY);
1521
}
1622
try {

0 commit comments

Comments
 (0)