Skip to content

Commit

Permalink
Merge branch 'fs/FC-952--Add-membership-effort-table-to-team-member-p…
Browse files Browse the repository at this point in the history
…age'
  • Loading branch information
j-fborges committed Sep 29, 2023
2 parents c1ff726 + 318d445 commit c3e9b09
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 11 deletions.
3 changes: 3 additions & 0 deletions app/graphql/types/demand_effort_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ class DemandEffortType < Types::BaseObject
field :total_blocked, Float, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
field :who, String, null: true
field :demand_id, Integer, null: false
field :team, Types::Teams::TeamType, null: false
field :demand_external_id, String, null: false
end
end
18 changes: 18 additions & 0 deletions app/graphql/types/teams/team_member_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ class TeamMemberType < Types::BaseObject
field :start_date, GraphQL::Types::ISO8601Date, null: true
field :teams, [Types::Teams::TeamType], null: true
field :user, Types::UserType, null: true
field :demand_efforts, [Types::DemandEffortType], null: true

field :latest_demand_efforts, [Types::DemandEffortType], null: true

field :demands, [Types::DemandType] do
argument :limit, Int, required: false
Expand Down Expand Up @@ -47,11 +50,26 @@ class TeamMemberType < Types::BaseObject
field :lead_time_histogram_chart_data, Types::Charts::LeadTimeHistogramDataType, null: true
field :member_effort_daily_data, Types::Charts::SimpleDateChartDataType, null: true
field :member_effort_data, Types::Charts::SimpleDateChartDataType, null: true

field :member_throughput_data, [Int], null: true do
argument :number_of_weeks, Int, required: false
end

field :project_hours_data, Types::Charts::ProjectHoursChartDataType, null: true

field :demand_efforts_list, [Types::DemandEffortType], null: true, description: 'A list of demand effort the arguments as search parameters' do
argument :from_date, GraphQL::Types::ISO8601Date, required: false
argument :until_date, GraphQL::Types::ISO8601Date, required: false
end

def demand_efforts_list(from_date: 1.month.ago.to_date, until_date: Time.zone.now.to_date)
object.demand_efforts.updated_between(from_date, until_date)
end

def latest_demand_efforts = object.demand_efforts.order(updated_at: :desc).limit(15)



def demands(status: 'ALL', type: 'ALL', limit: nil)
demands = if status == 'DELIVERED_DEMANDS'
object.demands.finished_until_date(Time.zone.now).order(end_date: :desc)
Expand Down
14 changes: 13 additions & 1 deletion app/models/demand_effort.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class DemandEffort < ApplicationRecord
scope :previous_in_day, ->(limit_time) { where('start_time_to_computation BETWEEN :start_time AND :end_time', start_time: limit_time.beginning_of_day, end_time: limit_time) }
scope :to_dates, ->(start_date, end_date) { where('start_time_to_computation BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date) }
scope :until_date, ->(limit_date) { where('start_time_to_computation <= :limit_date', limit_date: limit_date) }

scope :updated_between, ->(start_date, end_date) { where('demand_efforts.updated_at BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date).order(finish_time_to_computation: :desc) }


after_save :update_demand_caches

Expand All @@ -75,6 +78,14 @@ def who
item_assignment.team_member_name
end

def team
item_assignment.membership.team
end

def demand_external_id
item_assignment.demand.external_id
end

def stage
demand_transition.stage_name
end
Expand All @@ -86,7 +97,7 @@ def member_role
def effort_money
effort_value * demand.project.hour_value
end

private

def stage_percentage_value
Expand All @@ -104,4 +115,5 @@ def management_percentage_value
def update_demand_caches
DemandEffortService.instance.update_demand_effort_caches(demand)
end

end
88 changes: 87 additions & 1 deletion app/spa/src/components/TeamMemberDashboardTables.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
import { Grid, Link } from "@mui/material"
import { Button, FormGroup, Grid, Input, InputLabel, Link } from "@mui/material"
import { Link as RouterLink } from "react-router-dom"
import { useTranslation } from "react-i18next"

import { TeamMember } from "../modules/teamMember/teamMember.types"
import Table from "./ui/Table"
import { secondsToDays } from "../lib/date"
import DateLocale from "./ui/DateLocale"
import { FormElement } from "./ui/Form"
import { GridSearchIcon } from "@material-ui/data-grid"
import { FieldValues, useForm } from "react-hook-form"

type TeamMemberDashboardTablesProps = {
teamMember: TeamMember
effortsFilters: FieldValues
}

const TeamMemberDashboardTables = ({
teamMember,
effortsFilters,
}: TeamMemberDashboardTablesProps) => {
const { t } = useTranslation(["teamMembers"])
const { register } = useForm()

if (effortsFilters.fromDate === ""){
(effortsFilters.fromDate = new Date(new Date().setDate(new Date().getDate() - 30)))
}

if (effortsFilters.untilDate === ""){
(effortsFilters.untilDate = new Date())
}

const demandShortestLeadTime =
teamMember.demandShortestLeadTime?.leadtime || 0
const demandLargestLeadTime = teamMember.demandLargestLeadTime?.leadtime || 0
Expand Down Expand Up @@ -88,6 +103,7 @@ const TeamMemberDashboardTables = ({
t("dashboard.demandBlocks.blockTime"),
t("dashboard.demandBlocks.unblockTime"),
]

const demandBlocksRows =
teamMember.demandBlocksList?.demandBlocks?.map((block) => [
block.demand?.demandTitle || "",
Expand All @@ -103,6 +119,35 @@ const TeamMemberDashboardTables = ({
t("dashboard.latestProjects.quality"),
t("dashboard.latestProjects.leadTime"),
]

const latestEffortsHeader = [
t("dashboard.latestEfforts.name"),
t("dashboard.latestEfforts.team"),
t("dashboard.latestEfforts.effortDate"),
t("dashboard.latestEfforts.demands"),
t("dashboard.latestEfforts.effortValue"),
]

const latestEffortsRows =
teamMember?.demandEffortsList?.map((effort) => [
`${(effort.who || "")}`,
<Link
component={RouterLink}
to={`/companies/taller/teams/${effort.team?.id}`}
>
{effort.team?.name}
</Link>,
<DateLocale date={String(effort.updatedAt)} />,
<Link
component={RouterLink}
to={`/companies/taller/demands/${effort.demandExternalId}`}
>
{effort.demandExternalId}
</Link>,
`${(effort.effortValue || "")}`,

]) || []

const latestProjectsRows =
teamMember.projectsList?.projects?.map((project) => [
<Link
Expand Down Expand Up @@ -149,6 +194,47 @@ const TeamMemberDashboardTables = ({
rows={latestProjectsRows}
/>
</Grid>
<Grid item xs={12}>
<form>
<FormGroup sx={{ marginBottom: 8 }}>
<Grid container spacing={5}>
<FormElement>
<InputLabel htmlFor="fromDate" shrink>
{t("dashboard.latestEfforts.fromDate")}
</InputLabel>
<Input
type="date"
defaultValue={effortsFilters.fromDate}
{...register("fromDate")}
/>
</FormElement>

<FormElement>
<InputLabel htmlFor="untilDate" shrink>
{t("dashboard.latestEfforts.untilDate")}
</InputLabel>
<Input
type="date"
defaultValue={effortsFilters.untilDate}
{...register("untilDate")}
/>
</FormElement>

<FormElement>
<Button sx={{ alignSelf: "flex-start" }} type="submit">
<GridSearchIcon fontSize="large" color="primary" />
</Button>
</FormElement>

</Grid>
</FormGroup>
</form>
<Table
title={t("dashboard.latestEfforts.title")}
headerCells={latestEffortsHeader}
rows={latestEffortsRows}
/>
</Grid>
</Grid>
)
}
Expand Down
10 changes: 10 additions & 0 deletions app/spa/src/locales/coca/teamMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
"endDate": "Delivery Date",
"leadTime": "Lead Time"
},
"latestEfforts": {
"title": "Latest Efforts",
"name": "Name",
"team": "Team",
"effortDate": "Effort date",
"demands": "Demands",
"effortValue": "Effort Value",
"untilDate": "End Date",
"fromDate": "Start Date"
},
"teams": {
"title": "Teams"
},
Expand Down
10 changes: 10 additions & 0 deletions app/spa/src/locales/en/teamMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
"endDate": "Delivery Date",
"leadTime": "Lead Time"
},
"latestEfforts": {
"title": "Latest Efforts",
"name": "Name",
"team": "Team",
"effortDate": "Effort date",
"demands": "Demands",
"effortValue": "Effort Value",
"untilDate": "End Date",
"fromDate": "Start Date"
},
"teams": {
"title": "Teams"
},
Expand Down
10 changes: 10 additions & 0 deletions app/spa/src/locales/pt/teamMembers.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@
"endDate": "Dt Entrega",
"leadTime": "Lead Time"
},
"latestEfforts": {
"title": "Últimos Esforços",
"name": "Nome",
"team": "Time",
"effortDate": "Data do esforço",
"demands": "Demandas",
"effortValue": "Valor do esforço",
"untilDate": "Data final",
"fromDate": "Data inicial"
},
"teams": {
"title": "Times"
},
Expand Down
7 changes: 7 additions & 0 deletions app/spa/src/modules/demandEffort/demandEffort.types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Team } from "../team/team.types"

export type DemandEffort = {
id: string
effortValue?: number
Expand All @@ -12,6 +14,11 @@ export type DemandEffort = {
stage?: string
who?: string
memberRole?: string
updatedAt?: string
createdAt?: string
automaticUpdate?: boolean
membershipEffortPercentage?: number
team?: Team
demandId?: number
demandExternalId?: string
}
4 changes: 4 additions & 0 deletions app/spa/src/modules/teamMember/teamMember.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ProjectsList } from "../project/project.types"
import { Team } from "../team/team.types"
import User from "../user/user.types"
import { ChartAxisData, KeyValueData } from "../charts/charts.types"
import { DemandEffort } from "../demandEffort/demandEffort.types"

type LeadTimesChartData = {
xAxis: (string | number)[]
Expand All @@ -25,6 +26,8 @@ export type TeamMember = {
demandShortestLeadTime?: Demand
demandLargestLeadTime?: Demand
latestDeliveries?: Demand[]
latestDemandEfforts?: DemandEffort[]
demandEffortsList?: DemandEffort[]
demandLeadTimeP80?: number
projectsList?: ProjectsList
demandBlocksList?: DemandBlocksList
Expand All @@ -40,4 +43,5 @@ export type TeamMember = {
yAxisHours: number[]
yAxisProjectsNames: string[]
}
demandEfforts?: DemandEffort[]
}
Loading

0 comments on commit c3e9b09

Please sign in to comment.