Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions src/components/miners/MinerOpenDiscoveryIssuesByRepo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,20 @@ const getIssueCounts = (issues: RepositoryIssue[]) => ({
closed: issues.filter(isClosedIssue).length,
});

const applyIssueSearch = (
issues: RepositoryIssue[],
search: string,
): RepositoryIssue[] => {
const q = search.trim().toLowerCase();
if (!q) return issues;
return issues.filter(
(i) =>
i.title.toLowerCase().includes(q) ||
i.repositoryFullName.toLowerCase().includes(q) ||
String(i.number).includes(q),
);
};

const applyIssueFilter = (
issues: RepositoryIssue[],
filter: IssueFilter,
Expand All @@ -204,15 +218,7 @@ const applyIssueFilter = (
if (filter === 'open') result = result.filter(isOpenIssue);
else if (filter === 'solved') result = result.filter(isSolvedIssue);
else if (filter === 'closed') result = result.filter(isClosedIssue);
const q = search.trim().toLowerCase();
if (q) {
result = result.filter(
(i) =>
i.title.toLowerCase().includes(q) ||
i.repositoryFullName.toLowerCase().includes(q) ||
String(i.number).includes(q),
);
}
result = applyIssueSearch(result, search);
return [...result].sort((a, b) => {
let cmp = 0;
if (sortField === 'number') cmp = a.number - b.number;
Expand Down Expand Up @@ -426,8 +432,16 @@ const MinerOpenDiscoveryIssuesByRepo: React.FC<
const mineTotalPages = Math.ceil(filteredMine.length / PAGE_SIZE);
const otherTotalPages = Math.ceil(filteredOther.length / PAGE_SIZE);

const mineCounts = useMemo(() => getIssueCounts(mineIssues), [mineIssues]);
const otherCounts = useMemo(() => getIssueCounts(otherIssues), [otherIssues]);
// Count over the search scope (excluding the active status filter) so each
// button reflects what the user would see if they clicked it.
const mineCounts = useMemo(
() => getIssueCounts(applyIssueSearch(mineIssues, mineSearch)),
[mineIssues, mineSearch],
);
const otherCounts = useMemo(
() => getIssueCounts(applyIssueSearch(otherIssues, otherSearch)),
[otherIssues, otherSearch],
);

const mineColumns: DataTableColumn<RepositoryIssue, IssueSortField>[] =
useMemo(
Expand Down
12 changes: 10 additions & 2 deletions src/components/miners/MinerPRsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,18 @@ const MinerPRsTable: React.FC<MinerPRsTableProps> = ({ githubId }) => {

const totalPages = Math.ceil(sortedPRs.length / PAGE_SIZE);

// Count over the search + author scope (excluding the active status filter)
// so each button reflects what the user would see if they clicked it.
const statusCounts = useMemo(() => {
if (!prs) return { all: 0, open: 0, merged: 0, closed: 0 };
return getPrStatusCounts(prs);
}, [prs]);
const scope = filterPrs(prs, {
author: selectedAuthor,
includeNumber: true,
searchQuery,
statusFilter: 'all',
});
return getPrStatusCounts(scope);
}, [prs, selectedAuthor, searchQuery]);

const hasFilters =
Boolean(selectedAuthor) ||
Expand Down
36 changes: 19 additions & 17 deletions src/components/miners/MinerRepositoriesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,23 +130,25 @@ const MinerRepositoriesTable: React.FC<MinerRepositoriesTableProps> = ({
}
}, [issueRepoStats, statusFilter]);

const repoStatusCounts = useMemo(
() => ({
all: repoStats.length,
recent: repoStats.filter(isRecentRepoStats).length,
stale: repoStats.filter(isStaleRepoStats).length,
}),
[repoStats],
);

const issueRepoStatusCounts = useMemo(
() => ({
all: issueRepoStats.length,
recent: issueRepoStats.filter(isRecentIssueRepoStats).length,
stale: issueRepoStats.filter(isStaleIssueRepoStats).length,
}),
[issueRepoStats],
);
// Count over the search scope (excluding the active status filter) so each
// button reflects what the user would see if they clicked it.
const repoStatusCounts = useMemo(() => {
const scope = filterBySearch(repoStats, searchQuery);
return {
all: scope.length,
recent: scope.filter(isRecentRepoStats).length,
stale: scope.filter(isStaleRepoStats).length,
};
}, [repoStats, searchQuery]);

const issueRepoStatusCounts = useMemo(() => {
const scope = filterBySearch(issueRepoStats, searchQuery);
return {
all: scope.length,
recent: scope.filter(isRecentIssueRepoStats).length,
stale: scope.filter(isStaleIssueRepoStats).length,
};
}, [issueRepoStats, searchQuery]);

const filteredRepoStats = useMemo(
() => filterBySearch(statusFilteredRepoStats, searchQuery),
Expand Down
14 changes: 13 additions & 1 deletion src/components/miners/MinerScoreBreakdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1037,7 +1037,19 @@ const PrBreakdownView: React.FC<{ githubId: string }> = ({ githubId }) => {
if (!isMobile) setIsMobileSearchOpen(false);
}, [isMobile]);

const statusCounts = useMemo(() => getPrStatusCounts(prs ?? []), [prs]);
// Count over the search scope (excluding the active status filter) so each
// button reflects what the user would see if they clicked it.
const statusCounts = useMemo(
() =>
getPrStatusCounts(
filterPrs(prs ?? [], {
searchQuery,
includeNumber: true,
statusFilter: 'all',
}),
),
[prs, searchQuery],
);

const statusFilterTotal = useMemo(() => {
switch (statusFilter) {
Expand Down
Loading