Skip to content

Commit

Permalink
Renamed parameters
Browse files Browse the repository at this point in the history
Renamed `p` and `q` to `size_weight` and `count_weight`, respectively.
  • Loading branch information
kitswas committed Apr 25, 2023
1 parent 9ce9bde commit f2516d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions api/top-langs.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export default async (req, res) => {
layout,
langs_count,
exclude_repo,
p,
q,
size_weight,
count_weight,
custom_title,
locale,
border_radius,
Expand All @@ -48,8 +48,8 @@ export default async (req, res) => {
const topLangs = await fetchTopLanguages(
username,
parseArray(exclude_repo),
p,
q,
size_weight,
count_weight,
);

const cacheSeconds = clampValue(
Expand Down
10 changes: 8 additions & 2 deletions src/fetchers/top-languages-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@ const fetcher = (variables, token) => {
* @param {string[]} exclude_repo List of repositories to exclude.
* @returns {Promise<import("./types").TopLangData>} Top languages data.
*/
const fetchTopLanguages = async (username, exclude_repo = [], p = 1, q = 0) => {
const fetchTopLanguages = async (
username,
exclude_repo = [],
size_weight = 1,
count_weight = 0,
) => {
if (!username) throw new MissingParamError(["username"]);

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

const topLangs = Object.keys(repoNodes)
Expand Down

0 comments on commit f2516d6

Please sign in to comment.