Skip to content

Commit f2516d6

Browse files
committed
Renamed parameters
Renamed `p` and `q` to `size_weight` and `count_weight`, respectively.
1 parent 9ce9bde commit f2516d6

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

api/top-langs.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export default async (req, res) => {
2525
layout,
2626
langs_count,
2727
exclude_repo,
28-
p,
29-
q,
28+
size_weight,
29+
count_weight,
3030
custom_title,
3131
locale,
3232
border_radius,
@@ -48,8 +48,8 @@ export default async (req, res) => {
4848
const topLangs = await fetchTopLanguages(
4949
username,
5050
parseArray(exclude_repo),
51-
p,
52-
q,
51+
size_weight,
52+
count_weight,
5353
);
5454

5555
const cacheSeconds = clampValue(

src/fetchers/top-languages-fetcher.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,12 @@ const fetcher = (variables, token) => {
5454
* @param {string[]} exclude_repo List of repositories to exclude.
5555
* @returns {Promise<import("./types").TopLangData>} Top languages data.
5656
*/
57-
const fetchTopLanguages = async (username, exclude_repo = [], p = 1, q = 0) => {
57+
const fetchTopLanguages = async (
58+
username,
59+
exclude_repo = [],
60+
size_weight = 1,
61+
count_weight = 0,
62+
) => {
5863
if (!username) throw new MissingParamError(["username"]);
5964

6065
const res = await retryer(fetcher, { login: username });
@@ -136,7 +141,8 @@ const fetchTopLanguages = async (username, exclude_repo = [], p = 1, q = 0) => {
136141
Object.keys(repoNodes).forEach((name) => {
137142
// comparison index calculation
138143
repoNodes[name].size =
139-
Math.pow(repoNodes[name].size, p) * Math.pow(repoNodes[name].count, q);
144+
Math.pow(repoNodes[name].size, size_weight) *
145+
Math.pow(repoNodes[name].count, count_weight);
140146
});
141147

142148
const topLangs = Object.keys(repoNodes)

0 commit comments

Comments
 (0)