Skip to content

Commit

Permalink
feat: adding realized hours per month in the members efficiency table
Browse files Browse the repository at this point in the history
  • Loading branch information
celsoMartins committed Dec 4, 2023
1 parent 1a16ad8 commit 91c87d8
Show file tree
Hide file tree
Showing 11 changed files with 165 additions and 117 deletions.
1 change: 1 addition & 0 deletions app/graphql/types/teams/membership_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class MembershipType < Types::BaseObject
field :created_at, GraphQL::Types::ISO8601DateTime, null: false
field :effort_percentage, Float
field :end_date, GraphQL::Types::ISO8601Date
field :expected_hour_value, Float
field :hours_per_month, Integer
field :id, ID, null: false
field :member_role, Integer, null: false
Expand Down
6 changes: 6 additions & 0 deletions app/models/membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ def stages_to_work_on
stages_to_work_on
end

def expected_hour_value
return 0 if hours_per_month.zero?

monthly_payment / hours_per_month
end

def monthly_payment
return 0 if team_member.monthly_payment.blank?

Expand Down
4 changes: 2 additions & 2 deletions app/spa/src/components/ProjectDemandsCharts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ const ProjectDemandsCharts = ({
t("charts_tab.project_charts.demands_burn_up_label_ideal"),
t("charts_tab.project_charts.demands_burn_up_label_delivered"),
project.demandsBurnup
)
)

const projectHoursBurnupChartData = buildBurnupData(
t("charts_tab.project_charts.hours_burn_up_label_scope"),
t("charts_tab.project_charts.hours_burn_up_label_ideal"),
t("charts_tab.project_charts.hours_burn_up_label_delivered"),
project.hoursBurnup
)

const leadTimeP80ChartData = [
{
id: project.name,
Expand Down
47 changes: 23 additions & 24 deletions app/spa/src/components/TeamMemberDashboardCharts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,16 @@ const TeamMemberDashboardCharts = ({
const lineChartData = [
{
id: teamMember.name,
data: teamMember.teamMemberConsolidationList? teamMember.teamMemberConsolidationList.map(
({ valuePerHourPerformed, consolidationDate }) => {

return {
x: String(consolidationDate || ''),
y: Number(valuePerHourPerformed || 0),
}
}
) : [],
data: teamMember.teamMemberConsolidationList
? teamMember.teamMemberConsolidationList.map(
({ valuePerHourPerformed, consolidationDate }) => {
return {
x: String(consolidationDate || ""),
y: Number(valuePerHourPerformed || 0),
}
}
)
: [],
},
]

Expand Down Expand Up @@ -158,22 +159,20 @@ const TeamMemberDashboardCharts = ({
/>
</ChartGridItem>
)}
{projectHoursData && (
{projectHoursData && (
<ChartGridItem title={t("charts.valuePerHour")}>
<LineChart
data={lineChartData}
axisLeftLegend={t("charts.valuePerHour")}
axisBottomLegend={t(
"charts.memberEffort_x_label"
)}
props={{
enableSlices: "x",
sliceTooltip: ({ slice }: SliceTooltipProps) => (
<LineChartTooltip slice={slice} />
),
}}
/>
</ChartGridItem>
<LineChart
data={lineChartData}
axisLeftLegend={t("charts.valuePerHour")}
axisBottomLegend={t("charts.memberEffort_x_label")}
props={{
enableSlices: "x",
sliceTooltip: ({ slice }: SliceTooltipProps) => (
<LineChartTooltip slice={slice} />
),
}}
/>
</ChartGridItem>
)}
</Grid>
)
Expand Down
82 changes: 43 additions & 39 deletions app/spa/src/components/TeamMemberDashboardTables.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const TeamMemberDashboardTables = ({
const [searchParams, setSearchParams] = useSearchParams()

const normalizeQueryStringFilters = (filters: FieldValues) =>
Object.keys(filters)
.filter((key) => {
return String(filters[key]).length > 0 && filters[key] !== "null"
})
.reduce<Record<string, string>>((acc, el) => {
return { ...acc, [el]: filters[el] }
}, {})
Object.keys(filters)
.filter((key) => {
return String(filters[key]).length > 0 && filters[key] !== "null"
})
.reduce<Record<string, string>>((acc, el) => {
return { ...acc, [el]: filters[el] }
}, {})

const demandShortestLeadTime =
teamMember.demandShortestLeadTime?.leadtime || 0
Expand Down Expand Up @@ -130,23 +130,25 @@ const TeamMemberDashboardTables = ({
t("dashboard.latestEfforts.effortValue"),
]

const latestEffortsRows = teamMember?.demandEffortsList?.demandEfforts?.map((effort) => [
<Link
component={RouterLink}
to={`/companies/taller/teams/${effort.team?.id}`}
>
{effort.team?.name}
</Link>,
<DateLocale time date={String(effort.startTimeToComputation)} />,
<DateLocale time date={String(effort.finishTimeToComputation)} />,
<Link
component={RouterLink}
to={`/companies/taller/demands/${effort.demandExternalId}`}
>
{effort.demandExternalId}
</Link>,
`${(effort.effortValue || 0).toFixed(2)}`,
])
const latestEffortsRows = teamMember?.demandEffortsList?.demandEfforts?.map(
(effort) => [
<Link
component={RouterLink}
to={`/companies/taller/teams/${effort.team?.id}`}
>
{effort.team?.name}
</Link>,
<DateLocale time date={String(effort.startTimeToComputation)} />,
<DateLocale time date={String(effort.finishTimeToComputation)} />,
<Link
component={RouterLink}
to={`/companies/taller/demands/${effort.demandExternalId}`}
>
{effort.demandExternalId}
</Link>,
`${(effort.effortValue || 0).toFixed(2)}`,
]
)

const latestProjectsRows =
teamMember.projectsList?.projects?.map((project) => [
Expand Down Expand Up @@ -230,21 +232,23 @@ const TeamMemberDashboardTables = ({
</form>
{searchParams && (
<Table
title={t("dashboard.latestEfforts.title")}
subtitle={`${t("dashboard.latestEfforts.effortsValueSum")} ${teamMember?.demandEffortsList?.effortsValueSum || 0}`}
headerCells={latestEffortsHeader}
rows={latestEffortsRows || []}
pagination={{
count: (teamMember?.demandEffortsList?.demandEffortsCount|| 0),
rowsPerPage: (10),
page: effortsFilters.pageNumber - 1,
onPageChange: (_, newPage: number) =>
setSearchParams({
...normalizeQueryStringFilters(effortsFilters || {}),
pageNumber: String(newPage + 1),
}),
}}
/>
title={t("dashboard.latestEfforts.title")}
subtitle={`${t("dashboard.latestEfforts.effortsValueSum")} ${
teamMember?.demandEffortsList?.effortsValueSum || 0
}`}
headerCells={latestEffortsHeader}
rows={latestEffortsRows || []}
pagination={{
count: teamMember?.demandEffortsList?.demandEffortsCount || 0,
rowsPerPage: 10,
page: effortsFilters.pageNumber - 1,
onPageChange: (_, newPage: number) =>
setSearchParams({
...normalizeQueryStringFilters(effortsFilters || {}),
pageNumber: String(newPage + 1),
}),
}}
/>
)}
</Grid>
</Grid>
Expand Down
2 changes: 1 addition & 1 deletion app/spa/src/components/ui/DateLocale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type DateLocaleProps = {
isPtBr?: boolean
}

const DateLocale = ({ date, time, isPtBr = true}: DateLocaleProps) => {
const DateLocale = ({ date, time, isPtBr = true }: DateLocaleProps) => {
const dateFormat = isPtBr ? "dd/MM/yyyy" : "MM/dd/yyyy"
const format = time ? `${dateFormat} HH:mm` : dateFormat

Expand Down
5 changes: 3 additions & 2 deletions app/spa/src/modules/team/team.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Demand } from "../demand/demand.types"
import { ProjectConsolidation } from "../project/projectConsolidation.types"
import { ReplenishingConsolidation } from "../replenishing/replenishingConsolidation.types"


export type TeamMembersHourlyRate = {
periodDate?: string
valuePerHourPerformed?: number
Expand Down Expand Up @@ -66,6 +65,8 @@ export type MembershipEfficiencyData = {
realizedMoneyInMonth?: number
avgHoursPerDemand?: number
cardsCount?: number
expectedHourValue?: number
realizedHourValue?: number
}

export type Membership = {
Expand All @@ -75,10 +76,10 @@ export type Membership = {
teamMemberName?: string
hoursPerMonth?: number
effortPercentage?: number
expectedHourValue?: number
startDate?: string
endDate?: string
memberRole?: number
memberRoleDescription?: string
teamMembersHourlyRateList?: TeamMembersHourlyRate[]

}
12 changes: 7 additions & 5 deletions app/spa/src/modules/teamMember/teamMember.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,12 @@ export type TeamMember = {
yAxisProjectsNames: string[]
}
demandEfforts?: DemandEffort[]
demandEffortsList?: {
demandEfforts?: DemandEffort[]
demandEffortsCount?: number
effortsValueSum?: number
}
demandEffortsList?: DemandEffortsList
teamMemberConsolidationList?: TeamMemberConsolidation[]
}

type DemandEffortsList = {
demandEfforts?: DemandEffort[]
demandEffortsCount?: number
effortsValueSum?: number
}
69 changes: 41 additions & 28 deletions app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import TeamMemberDashboardCharts from "../../components/TeamMemberDashboardChart
import { FieldValues } from "react-hook-form"

const TEAM_MEMBER_QUERY = gql`
query TeamMember($id: ID!, $fromDate: ISO8601Date, $untilDate: ISO8601Date, $pageNumber: Int) {
query TeamMember(
$id: ID!
$fromDate: ISO8601Date
$untilDate: ISO8601Date
$pageNumber: Int
) {
teamMember(id: $id) {
id
name
Expand Down Expand Up @@ -116,7 +121,11 @@ const TEAM_MEMBER_QUERY = gql`
slug
}
}
demandEfforts(fromDate: $fromDate, untilDate: $untilDate, pageNumber: $pageNumber) {
demandEfforts(
fromDate: $fromDate
untilDate: $untilDate
pageNumber: $pageNumber
) {
id
effortValue
effortMoney
Expand All @@ -141,35 +150,39 @@ const TEAM_MEMBER_QUERY = gql`
automaticUpdate
membershipEffortPercentage
}
teamMemberConsolidationList{
teamMemberConsolidationList {
consolidationDate
valuePerHourPerformed
}
demandEffortsList(fromDate: $fromDate, untilDate: $untilDate, pageNumber: $pageNumber) {
demandEfforts{
id
effortValue
effortMoney
startTimeToComputation
finishTimeToComputation
stagePercentage
pairingPercentage
managementPercentage
totalBlocked
mainEffortInTransition
stage
who
team {
demandEffortsList(
fromDate: $fromDate
untilDate: $untilDate
pageNumber: $pageNumber
) {
demandEfforts {
id
name
}
createdAt
updatedAt
demandId
demandExternalId
memberRole
automaticUpdate
membershipEffortPercentage
effortValue
effortMoney
startTimeToComputation
finishTimeToComputation
stagePercentage
pairingPercentage
managementPercentage
totalBlocked
mainEffortInTransition
stage
who
team {
id
name
}
createdAt
updatedAt
demandId
demandExternalId
memberRole
automaticUpdate
membershipEffortPercentage
}
demandEffortsCount
effortsValueSum
Expand Down Expand Up @@ -207,7 +220,7 @@ const TeamMemberDashboard = () => {
id: Number(teamMemberId),
fromDate: effortsQueryFilters.fromDate,
untilDate: effortsQueryFilters.untilDate,
pageNumber: (effortsQueryFilters.pageNumber || 1),
pageNumber: effortsQueryFilters.pageNumber || 1,
},
})
const companySlug = me?.currentCompany?.slug
Expand Down
Loading

0 comments on commit 91c87d8

Please sign in to comment.