fix(pullsCounter): only show open pulls in counter@@ -5,6 +5,7 @@ import styled, { css } from "styled-components";
import type { LayoutProps, WithThemeSchemeProp } from "../types";
import { Const } from "../const";
import { NamedColors } from "../utils/style";
+import { removeCommentsAndSpacing } from "../utils/shared";
// app islands
import InstantRouterIndicator from "../islands/InstantRouterIndicator";
// app components
@@ -14,10 +15,6 @@ import { DrawerPrimary } from "./DrawerPrimary";
const BRANDLINE_HEIGHT = 4;
const HEADER_HEIGHT = 64;
-function removeCommentsAndSpacing(str = "") {
- return str.replace(/\/\*.*\*\//g, " ").replace(/\s+/g, " ");
-}
-
// Default Layout implementation.
// (dataloading happens through HOC at export level lower in file)
const LayoutComponent: FC<LayoutProps & WithThemeSchemeProp> = (props) => {
@@ -37,13 +37,15 @@ const makeGetRepositoryCounters: ServiceMethodFactory<
return DEFAULT_COUNTERS;
}
- // retrieve total pulls in repository (PRs targeting this repo)
- const totalPulls = await request.prisma.pullRequest.count({
+ // retrieve open pulls count in repository (PRs targeting this repo)
+ const openPulls = await request.prisma.pullRequest.count({
where: {
targetRepository: {
organization: { slug: orgSlug },
slug: repoSlug,
},
+ state: "OPEN",
+ closedAt: null,
},
});
@@ -54,7 +56,7 @@ const makeGetRepositoryCounters: ServiceMethodFactory<
branches: 0,
tags: 0,
commits: 0,
- pulls: totalPulls,
+ pulls: openPulls,
tests: 0,
builds: 0,
issues: 0,
@@ -3,3 +3,4 @@ export { default as buildRouteLink } from "./buildRouteLink";
export { default as getFormEntries } from "./getFormEntries";
export { default as getGitdiffLineStart } from "./getGitdiffLineStart";
export { default as slugify } from "./slugify";
+export { default as removeCommentsAndSpacing } from "./removeCommentsAndSpacing";
@@ -0,0 +1,9 @@
+/**
+ * Removes comments and extra spacing from a string.
+ *
+ * @param str The string to process.
+ * @returns The processed string.
+ */
+export default function removeCommentsAndSpacing(str = "") {
+ return str.replace(/\/\*.*\*\//g, " ").replace(/\s+/g, " ");
+}