repo card: fix repo and owner filter again

This commit is contained in:
martin-mfg
2025-05-23 18:11:03 +00:00
parent 8415848d13
commit 2b521ddc81
2 changed files with 20 additions and 9 deletions
+12 -4
View File
@@ -8,7 +8,8 @@ import {
flexLayout,
getCardColors,
kFormatter,
measureText, buildSearchFilter,
measureText,
buildSearchFilter,
} from "../common/utils.js";
import { statCardLocales } from "../translations.js";
@@ -34,6 +35,7 @@ const RANK_ONLY_CARD_DEFAULT_WIDTH = 290;
* @param {boolean} createTextNodeParams.bold Whether to bold the label.
* @param {string} createTextNodeParams.number_format The format of numbers on card.
* @param {string} createTextNodeParams.link Url to link to.
* @param {number} createTextNodeParams.labelXOffset horizontal offset for label.
* @returns {string} The stats card text item SVG object.
*/
const createTextNode = ({
@@ -48,7 +50,7 @@ const createTextNode = ({
bold,
number_format,
link,
labelXOffset=25,
labelXOffset = 25,
}) => {
const kValue =
number_format.toLowerCase() === "long" ? value : kFormatter(value);
@@ -208,7 +210,13 @@ const getStyles = ({
* @param {Partial<StatCardOptions>} options The card options.
* @returns {string} The stats card SVG object.
*/
const renderStatsCard = (stats, options = {}, username, repos=[], owners=[]) => {
const renderStatsCard = (
stats,
options = {},
username,
repos = [],
owners = [],
) => {
const {
name,
totalStars,
@@ -352,7 +360,7 @@ const renderStatsCard = (stats, options = {}, username, repos=[], owners=[]) =>
};
}
let repoFilter = encodeURIComponent(buildSearchFilter([nameWithOwner], []));
let repoFilter = encodeURIComponent(buildSearchFilter(repos, owners));
if (show.includes("prs_authored")) {
STATS.prs_authored = {
icon: icons.prs,
+8 -5
View File
@@ -182,7 +182,10 @@ const totalItemsFetcher = async (username, repos, owners, type, filter) => {
`https://api.github.com/search/` +
type +
`?per_page=1&q=` +
buildSearchFilter(variables.repos, variables.owners)+
buildSearchFilter(variables.repos, variables.owners).replaceAll(
" ",
"+",
) +
filter,
headers: {
"Content-Type": "application/json",
@@ -218,7 +221,7 @@ const fetchRepoUserStats = async (
include_prs_commented,
include_prs_reviewed,
include_issues_authored,
include_issues_commented
include_issues_commented,
) => {
let stats = {};
if (include_prs_authored) {
@@ -291,8 +294,8 @@ const fetchStats = async (
include_merged_pull_requests = false,
include_discussions = false,
include_discussions_answers = false,
repos=[],
owners=[],
repos = [],
owners = [],
include_prs_authored = false,
include_prs_commented = false,
include_prs_reviewed = false,
@@ -375,7 +378,7 @@ const fetchStats = async (
include_prs_commented,
include_prs_reviewed,
include_issues_authored,
include_issues_commented
include_issues_commented,
);
Object.assign(stats, repoUserStats);