fix tests, rename "owners"->"owner" and "repos"->"repo"

This commit is contained in:
martin-mfg
2025-08-06 08:35:09 +02:00
parent 367b89f0a6
commit 2f23ff5958
5 changed files with 50 additions and 46 deletions
+3 -3
View File
@@ -214,8 +214,8 @@ const renderStatsCard = (
stats,
options = {},
username,
repos = [],
owners = [],
repo = [],
owner = [],
) => {
const {
name,
@@ -360,7 +360,7 @@ const renderStatsCard = (
};
}
let repoFilter = encodeURIComponent(buildSearchFilter(repos, owners));
let repoFilter = encodeURIComponent(buildSearchFilter(repo, owner));
if (show.includes("prs_authored")) {
STATS.prs_authored = {
icon: icons.prs,
+28 -24
View File
@@ -134,7 +134,7 @@ const statsFetcher = async ({
includeMergedPullRequests,
includeDiscussions,
includeDiscussionsAnswers,
ownerAffiliations: ownerAffiliations,
ownerAffiliations,
};
let res = await retryer(fetcher, variables);
if (res.data.errors) {
@@ -172,7 +172,7 @@ const statsFetcher = async ({
* @description Done like this because the GitHub API does not provide a way to fetch all the commits. See
* #92#issuecomment-661026467 and #211 for more information.
*/
const totalItemsFetcher = async (username, repos, owners, type, filter) => {
const totalItemsFetcher = async (username, repo, owner, type, filter) => {
if (!githubUsernameRegex.test(username)) {
logger.log("Invalid username provided.");
throw new Error("Invalid username provided.");
@@ -186,7 +186,7 @@ const totalItemsFetcher = async (username, repos, owners, type, filter) => {
`https://api.github.com/search/` +
type +
`?per_page=1&q=` +
buildSearchFilter(variables.repos, variables.owners).replaceAll(
buildSearchFilter(variables.repo, variables.owner).replaceAll(
" ",
"+",
) +
@@ -201,7 +201,11 @@ const totalItemsFetcher = async (username, repos, owners, type, filter) => {
let res;
try {
res = await retryer(fetchTotalItems, { login: username, repos, owners });
res = await retryer(fetchTotalItems, {
login: username,
repo,
owner,
});
} catch (err) {
logger.log(err);
throw new Error(err);
@@ -219,8 +223,8 @@ const totalItemsFetcher = async (username, repos, owners, type, filter) => {
const fetchRepoUserStats = async (
username,
repos,
owners,
repo,
owner,
include_prs_authored,
include_prs_commented,
include_prs_reviewed,
@@ -231,8 +235,8 @@ const fetchRepoUserStats = async (
if (include_prs_authored) {
stats.totalPRsAuthored = await totalItemsFetcher(
username,
repos,
owners,
repo,
owner,
"issues",
`author:${username}+type:pr`,
);
@@ -240,8 +244,8 @@ const fetchRepoUserStats = async (
if (include_prs_commented) {
stats.totalPRsCommented = await totalItemsFetcher(
username,
repos,
owners,
repo,
owner,
"issues",
`commenter:${username}+-author:${username}+type:pr`,
);
@@ -249,8 +253,8 @@ const fetchRepoUserStats = async (
if (include_prs_reviewed) {
stats.totalPRsReviewed = await totalItemsFetcher(
username,
repos,
owners,
repo,
owner,
"issues",
`reviewed-by:${username}+-author:${username}+type:pr`,
);
@@ -258,8 +262,8 @@ const fetchRepoUserStats = async (
if (include_issues_authored) {
stats.totalIssuesAuthored = await totalItemsFetcher(
username,
repos,
owners,
repo,
owner,
"issues",
`author:${username}+type:issue`,
);
@@ -267,8 +271,8 @@ const fetchRepoUserStats = async (
if (include_issues_commented) {
stats.totalIssuesCommented = await totalItemsFetcher(
username,
repos,
owners,
repo,
owner,
"issues",
`commenter:${username}+-author:${username}+type:issue`,
);
@@ -286,27 +290,27 @@ const fetchRepoUserStats = async (
* @param {string} username GitHub username.
* @param {boolean} include_all_commits Include all commits.
* @param {string[]} exclude_repo Repositories to exclude.
* @param {string[]} ownerAffiliations Owner affiliations. Default: OWNER.
* @param {boolean} include_merged_pull_requests Include merged pull requests.
* @param {boolean} include_discussions Include discussions.
* @param {boolean} include_discussions_answers Include discussions answers.
* @param {string[]} ownerAffiliations Owner affiliations. Default: OWNER.
* @returns {Promise<StatsData>} Stats data.
*/
const fetchStats = async (
username,
include_all_commits = false,
exclude_repo = [],
ownerAffiliations = [],
include_merged_pull_requests = false,
include_discussions = false,
include_discussions_answers = false,
repos = [],
owners = [],
repo = [],
owner = [],
include_prs_authored = false,
include_prs_commented = false,
include_prs_reviewed = false,
include_issues_authored = false,
include_issues_commented = false,
ownerAffiliations = [],
) => {
if (!username) {
throw new MissingParamError(["username"]);
@@ -370,8 +374,8 @@ const fetchStats = async (
if (include_all_commits) {
stats.totalCommits = await totalItemsFetcher(
username,
repos,
owners,
repo,
owner,
"commits",
`author:${username}`,
);
@@ -380,8 +384,8 @@ const fetchStats = async (
}
let repoUserStats = await fetchRepoUserStats(
username,
repos,
owners,
repo,
owner,
include_prs_authored,
include_prs_commented,
include_prs_reviewed,
+1 -1
View File
@@ -62,9 +62,9 @@ const fetcher = (variables, token) => {
*
* @param {string} username GitHub username.
* @param {string[]} exclude_repo List of repositories to exclude. Default: [].
* @param {string[]} ownerAffiliations The owner affiliations to filter by. Default: OWNER.
* @param {number} size_weight Weightage to be given to size.
* @param {number} count_weight Weightage to be given to count.
* @param {string[]} ownerAffiliations The owner affiliations to filter by. Default: OWNER.
* @returns {Promise<TopLangData>} Top languages data.
*/
const fetchTopLanguages = async (