Skip to content

Commit

Permalink
feat: add bugs chart to status report
Browse files Browse the repository at this point in the history
  • Loading branch information
lhguerra committed Dec 13, 2024
1 parent 77423a1 commit d1d291e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 45 deletions.
41 changes: 3 additions & 38 deletions app/spa/src/components/Projects/ProjectDemandsCharts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { buildBurnupData } from "../../utils/charts"
import ProjectBurnup from "../../pages/Projects/Charts/ProjectBurnup"
import ProjectLeadTime from "../../pages/Projects/Charts/ProjectLeadTime"
import ProjectLeadTimeControlChart from "../../pages/Projects/Charts/ProjectLeadTimeControlChart"
import ProjectBugsPercentage from "../../pages/Projects/Charts/ProjectBugsPercentage"

type ProjectDemandsChartsProps = {
project: Project
Expand Down Expand Up @@ -120,19 +121,6 @@ const ProjectDemandsCharts = ({
project.hoursBurnup
)

const projectQualityChartData = [
{
id: project.name || "",
data:
projectConsolidationsWeekly?.map(
({ consolidationDate, projectQuality }) => ({
x: consolidationDate,
y: (1 - projectQuality) * 100,
})
) || [],
},
]

const projectQualityForCodingChartData = [
{
id: project.name || "",
Expand Down Expand Up @@ -443,31 +431,8 @@ const ProjectDemandsCharts = ({
</ChartGridItem>
)}

<ChartGridItem title={t("chartsTab.projectCharts.quality_bugs_chart")}>
<LineChart
data={projectQualityChartData}
axisLeftLegend="%"
props={{
margin: { left: 80, right: 20, top: 25, bottom: 65 },
axisBottom: {
tickSize: 5,
tickPadding: 5,
legendPosition: "middle",
legendOffset: 60,
tickRotation: -40,
legend: t("chartsTab.projectCharts.quality_bugs_x_label"),
},
yFormat: (value: number) => `${value.toFixed(2)}%`,
enableSlices: "x",
sliceTooltip: ({ slice }: SliceTooltipProps) => (
<LineChartTooltip
slice={slice}
xLabel={t("chartsTab.projectCharts.quality_bugs_tooltip_label")}
/>
),
}}
/>
</ChartGridItem>
<ProjectBugsPercentage project={project} />

<ChartGridItem
title={t("chartsTab.projectCharts.quality_bugs_for_coding_chart")}
>
Expand Down
58 changes: 58 additions & 0 deletions app/spa/src/pages/Projects/Charts/ProjectBugsPercentage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { LineChart } from "../../../components/charts/LineChart"
import { SliceTooltipProps } from "@nivo/line"
import LineChartTooltip from "../../../components/charts/tooltips/LineChartTooltip"
import { ChartGridItem } from "../../../components/charts/ChartGridItem"
import { Project } from "../../../modules/project/project.types"
import { useTranslation } from "react-i18next"

const ProjectBugsPercentage = ({ project }: ProjectBugsPercentageProps) => {
const { t } = useTranslation(["projectChart"])

const projectConsolidationsWeekly = project.projectConsolidationsWeekly
const projectQualityChartData = [
{
id: project.name || "",
data:
projectConsolidationsWeekly?.map(
({ consolidationDate, projectQuality }) => ({
x: consolidationDate,
y: (1 - projectQuality) * 100,
})
) || [],
},
]

return (
<ChartGridItem title={t("chartsTab.projectCharts.quality_bugs_chart")}>
<LineChart
data={projectQualityChartData}
axisLeftLegend="%"
props={{
margin: { left: 80, right: 20, top: 25, bottom: 65 },
axisBottom: {
tickSize: 5,
tickPadding: 5,
legendPosition: "middle",
legendOffset: 60,
tickRotation: -40,
legend: t("chartsTab.projectCharts.quality_bugs_x_label"),
},
yFormat: (value: number) => `${value.toFixed(2)}%`,
enableSlices: "x",
sliceTooltip: ({ slice }: SliceTooltipProps) => (
<LineChartTooltip
slice={slice}
xLabel={t("chartsTab.projectCharts.quality_bugs_tooltip_label")}
/>
),
}}
/>
</ChartGridItem>
)
}

type ProjectBugsPercentageProps = {
project: Project
}

export default ProjectBugsPercentage
11 changes: 4 additions & 7 deletions app/spa/src/pages/Projects/Statistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@ import { ReactElement } from "react"
import { useParams } from "react-router-dom"
import { LineChart } from "../../components/charts/LineChart"
import {
ProjectPage,
PROJECT_STANDARD_FRAGMENT,
ProjectPage,
} from "../../components/Projects/ProjectPage"
import { Project } from "../../modules/project/project.types"
import { ProjectConsolidation } from "../../modules/project/projectConsolidation.types"

const ONE_DAY_IN_SECONDS = 60 * 60 * 24

// @TODO: projectConsolidations should exist inside project field.
export const PROJECT_STATISTICS_QUERY = gql`
query ProjectStatistics($id: ID!) {
project(id: $id) {
Expand All @@ -39,13 +38,11 @@ export const PROJECT_STATISTICS_QUERY = gql`
${PROJECT_STANDARD_FRAGMENT}
`

type ProjectStatisticsResult = {
project: Project
projectConsolidations: ProjectConsolidation[]
type ProjectStatisticsDTO = {
project?: Project
projectConsolidations?: ProjectConsolidation[]
}

type ProjectStatisticsDTO = ProjectStatisticsResult | undefined

type GraphBoxProps = {
title: string
children: ReactElement | ReactElement[]
Expand Down
2 changes: 2 additions & 0 deletions app/spa/src/pages/Projects/StatusReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ProjectBurnup from "./Charts/ProjectBurnup"
import ProjectHoursBurnup from "./Charts/ProjectHoursBurnup"
import ProjectLeadTime from "./Charts/ProjectLeadTime"
import ProjectLeadTimeControlChart from "./Charts/ProjectLeadTimeControlChart"
import ProjectBugsPercentage from "./Charts/ProjectBugsPercentage"

export const QUERY = gql`
query ProjectStatusReport($id: ID!) {
Expand Down Expand Up @@ -98,6 +99,7 @@ const StatusReport = () => {
<ProjectHoursBurnup project={project} />
<ProjectLeadTime project={project} />
<ProjectLeadTimeControlChart project={project} />
<ProjectBugsPercentage project={project} />
</Grid>
</Box>
)}
Expand Down

0 comments on commit d1d291e

Please sign in to comment.