From 8e366cf776176933206c019567fea0db767f789c Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Mon, 25 Sep 2023 16:16:22 -0300 Subject: [PATCH 01/19] Feat: Add membership effort tabe to team member page --- app/graphql/types/teams/team_member_type.rb | 1 + .../components/TeamMemberDashboardTables.tsx | 7 +++++++ app/spa/src/locales/coca/teamMembers.json | 8 ++++++++ app/spa/src/locales/en/teamMembers.json | 8 ++++++++ app/spa/src/locales/pt/teamMembers.json | 8 ++++++++ .../src/modules/teamMember/teamMember.types.ts | 2 ++ .../pages/TeamMembers/TeamMemberDashboard.tsx | 17 +++++++++++++++++ 7 files changed, 51 insertions(+) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index c8756428e..7b517c9db 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -14,6 +14,7 @@ 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 :demands, [Types::DemandType] do argument :limit, Int, required: false diff --git a/app/spa/src/components/TeamMemberDashboardTables.tsx b/app/spa/src/components/TeamMemberDashboardTables.tsx index 6cf4e7830..b8725e076 100644 --- a/app/spa/src/components/TeamMemberDashboardTables.tsx +++ b/app/spa/src/components/TeamMemberDashboardTables.tsx @@ -149,6 +149,13 @@ const TeamMemberDashboardTables = ({ rows={latestProjectsRows} /> + + + ) } diff --git a/app/spa/src/locales/coca/teamMembers.json b/app/spa/src/locales/coca/teamMembers.json index c6683e0ee..9cf2ff7f1 100644 --- a/app/spa/src/locales/coca/teamMembers.json +++ b/app/spa/src/locales/coca/teamMembers.json @@ -77,6 +77,14 @@ "endDate": "Delivery Date", "leadTime": "Lead Time" }, + "latestEfforts": { + "title": "Latest Efforts", + "project": "Project", + "product": "Product", + "externalId": "External ID", + "endDate": "Delivery Date", + "leadTime": "Lead Time" + }, "teams": { "title": "Teams" }, diff --git a/app/spa/src/locales/en/teamMembers.json b/app/spa/src/locales/en/teamMembers.json index 3f230bf06..4d1abf76c 100644 --- a/app/spa/src/locales/en/teamMembers.json +++ b/app/spa/src/locales/en/teamMembers.json @@ -77,6 +77,14 @@ "endDate": "Delivery Date", "leadTime": "Lead Time" }, + "latestEfforts": { + "title": "Latest Efforts", + "project": "Project", + "product": "Product", + "externalId": "External ID", + "endDate": "Delivery Date", + "leadTime": "Lead Time" + }, "teams": { "title": "Teams" }, diff --git a/app/spa/src/locales/pt/teamMembers.json b/app/spa/src/locales/pt/teamMembers.json index 27bae0e88..8d58dd5eb 100644 --- a/app/spa/src/locales/pt/teamMembers.json +++ b/app/spa/src/locales/pt/teamMembers.json @@ -77,6 +77,14 @@ "endDate": "Dt Entrega", "leadTime": "Lead Time" }, + "latestEfforts": { + "title": "Últimos esforços", + "project": "Projeto", + "product": "Produto", + "externalId": "ID Externo", + "endDate": "Dt Entrega", + "leadTime": "Lead Time" + }, "teams": { "title": "Times" }, diff --git a/app/spa/src/modules/teamMember/teamMember.types.ts b/app/spa/src/modules/teamMember/teamMember.types.ts index 4d3b42245..5f78ff424 100644 --- a/app/spa/src/modules/teamMember/teamMember.types.ts +++ b/app/spa/src/modules/teamMember/teamMember.types.ts @@ -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)[] @@ -40,4 +41,5 @@ export type TeamMember = { yAxisHours: number[] yAxisProjectsNames: string[] } + demandEfforts?: DemandEffort[] } diff --git a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx index a343e3719..dcdf348fe 100644 --- a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx +++ b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx @@ -115,6 +115,23 @@ const TEAM_MEMBER_QUERY = gql` slug } } + demandEfforts { + id + effortValue + effortMoney + startTimeToComputation + finishTimeToComputation + stagePercentage + pairingPercentage + managementPercentage + totalBlocked + mainEffortInTransition + stage + who + memberRole + automaticUpdate + membershipEffortPercentage + } } } ` From cf9350f7f4b40430793ed38cc53898e2047fea9b Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Tue, 26 Sep 2023 10:11:19 -0300 Subject: [PATCH 02/19] feat: add method latest_deliveries_demands_effort --- app/graphql/types/teams/team_member_type.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index 7b517c9db..bc08f4a1d 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -16,6 +16,8 @@ class TeamMemberType < Types::BaseObject field :user, Types::UserType, null: true field :demand_efforts, [Types::DemandEffortType], null: true + field :latest_deliveries_demands_effort, [Types::DemandType], null: true + field :demands, [Types::DemandType] do argument :limit, Int, required: false argument :status, Types::Enums::DemandStatusesType, required: false @@ -53,6 +55,10 @@ class TeamMemberType < Types::BaseObject end field :project_hours_data, Types::Charts::ProjectHoursChartDataType, null: true + def latest_deliveries_demands_effort + object.demands.order(end_date: :desc).limit(15) + end + 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) From 0b91b4ac75148207f0df1f992eb4c94776b4b0bd Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Tue, 26 Sep 2023 10:39:05 -0300 Subject: [PATCH 03/19] feat: added latestDeliveriesDemandsEfforts field to frontend --- app/spa/src/modules/teamMember/teamMember.types.ts | 1 + app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/spa/src/modules/teamMember/teamMember.types.ts b/app/spa/src/modules/teamMember/teamMember.types.ts index 5f78ff424..81b42e81c 100644 --- a/app/spa/src/modules/teamMember/teamMember.types.ts +++ b/app/spa/src/modules/teamMember/teamMember.types.ts @@ -26,6 +26,7 @@ export type TeamMember = { demandShortestLeadTime?: Demand demandLargestLeadTime?: Demand latestDeliveries?: Demand[] + latestDeliveriesDemandsEffort?: DemandEffort[] demandLeadTimeP80?: number projectsList?: ProjectsList demandBlocksList?: DemandBlocksList diff --git a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx index dcdf348fe..2ae17d8cc 100644 --- a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx +++ b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx @@ -115,7 +115,7 @@ const TEAM_MEMBER_QUERY = gql` slug } } - demandEfforts { + latestDeliveriesDemandsEfforts { id effortValue effortMoney From 4829a02f928b4843f01c669129302ad3d1026690 Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Tue, 26 Sep 2023 12:26:23 -0300 Subject: [PATCH 04/19] Feat: Added demands efforts table to team member page --- .../components/TeamMemberDashboardTables.tsx | 35 +++++++++++++++++-- app/spa/src/locales/coca/teamMembers.json | 10 +++--- app/spa/src/locales/en/teamMembers.json | 10 +++--- app/spa/src/locales/pt/teamMembers.json | 12 +++---- .../demandEffort/demandEffort.types.ts | 7 ++++ .../modules/teamMember/teamMember.types.ts | 2 +- .../pages/TeamMembers/TeamMemberDashboard.tsx | 10 +++++- 7 files changed, 65 insertions(+), 21 deletions(-) diff --git a/app/spa/src/components/TeamMemberDashboardTables.tsx b/app/spa/src/components/TeamMemberDashboardTables.tsx index b8725e076..bdc577338 100644 --- a/app/spa/src/components/TeamMemberDashboardTables.tsx +++ b/app/spa/src/components/TeamMemberDashboardTables.tsx @@ -103,6 +103,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?.latestDemandEfforts?.map((effort) => [ + `${(effort.who || "")}`, + + {effort.team?.name} + , + , + + {effort.demandExternalId} + , + `${(effort.effortValue || "")}`, + + ]) || [] + const latestProjectsRows = teamMember.projectsList?.projects?.map((project) => [ - +
diff --git a/app/spa/src/locales/coca/teamMembers.json b/app/spa/src/locales/coca/teamMembers.json index 9cf2ff7f1..90d42030a 100644 --- a/app/spa/src/locales/coca/teamMembers.json +++ b/app/spa/src/locales/coca/teamMembers.json @@ -79,11 +79,11 @@ }, "latestEfforts": { "title": "Latest Efforts", - "project": "Project", - "product": "Product", - "externalId": "External ID", - "endDate": "Delivery Date", - "leadTime": "Lead Time" + "name": "Name", + "team": "Team", + "effortDate": "Effort date", + "demands": "Demands", + "effortValue": "effort Value" }, "teams": { "title": "Teams" diff --git a/app/spa/src/locales/en/teamMembers.json b/app/spa/src/locales/en/teamMembers.json index 4d1abf76c..34400dddd 100644 --- a/app/spa/src/locales/en/teamMembers.json +++ b/app/spa/src/locales/en/teamMembers.json @@ -79,11 +79,11 @@ }, "latestEfforts": { "title": "Latest Efforts", - "project": "Project", - "product": "Product", - "externalId": "External ID", - "endDate": "Delivery Date", - "leadTime": "Lead Time" + "name": "Name", + "team": "Team", + "effortDate": "Effort date", + "demands": "Demands", + "effortValue": "effort Value" }, "teams": { "title": "Teams" diff --git a/app/spa/src/locales/pt/teamMembers.json b/app/spa/src/locales/pt/teamMembers.json index 8d58dd5eb..a4afa46e8 100644 --- a/app/spa/src/locales/pt/teamMembers.json +++ b/app/spa/src/locales/pt/teamMembers.json @@ -78,12 +78,12 @@ "leadTime": "Lead Time" }, "latestEfforts": { - "title": "Últimos esforços", - "project": "Projeto", - "product": "Produto", - "externalId": "ID Externo", - "endDate": "Dt Entrega", - "leadTime": "Lead Time" + "title": "Últimos Esforços", + "name": "Nome", + "team": "Time", + "effortDate": "Data do esforço", + "demands": "Demandas", + "effortValue": "Valor do esforço" }, "teams": { "title": "Times" diff --git a/app/spa/src/modules/demandEffort/demandEffort.types.ts b/app/spa/src/modules/demandEffort/demandEffort.types.ts index fa1c40929..d3f4b57db 100644 --- a/app/spa/src/modules/demandEffort/demandEffort.types.ts +++ b/app/spa/src/modules/demandEffort/demandEffort.types.ts @@ -1,3 +1,5 @@ +import { Team } from "../team/team.types" + export type DemandEffort = { id: string effortValue?: number @@ -12,6 +14,11 @@ export type DemandEffort = { stage?: string who?: string memberRole?: string + updatedAt?: Date + createdAt?: Date automaticUpdate?: boolean membershipEffortPercentage?: number + team?: Team + demandId?: number + demandExternalId?: string } diff --git a/app/spa/src/modules/teamMember/teamMember.types.ts b/app/spa/src/modules/teamMember/teamMember.types.ts index 81b42e81c..a3d8ba299 100644 --- a/app/spa/src/modules/teamMember/teamMember.types.ts +++ b/app/spa/src/modules/teamMember/teamMember.types.ts @@ -26,7 +26,7 @@ export type TeamMember = { demandShortestLeadTime?: Demand demandLargestLeadTime?: Demand latestDeliveries?: Demand[] - latestDeliveriesDemandsEffort?: DemandEffort[] + latestDemandEfforts?: DemandEffort[] demandLeadTimeP80?: number projectsList?: ProjectsList demandBlocksList?: DemandBlocksList diff --git a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx index 2ae17d8cc..6704a0764 100644 --- a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx +++ b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx @@ -115,7 +115,7 @@ const TEAM_MEMBER_QUERY = gql` slug } } - latestDeliveriesDemandsEfforts { + latestDemandEfforts { id effortValue effortMoney @@ -128,6 +128,14 @@ const TEAM_MEMBER_QUERY = gql` mainEffortInTransition stage who + team { + id + name + } + createdAt + updatedAt + demandId + demandExternalId memberRole automaticUpdate membershipEffortPercentage From 2c00885e7219426749063e6687b87e08d5886dd8 Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Tue, 26 Sep 2023 14:49:33 -0300 Subject: [PATCH 05/19] uncommited changes --- app/graphql/types/demand_effort_type.rb | 3 +++ app/graphql/types/query_type.rb | 4 ++++ app/graphql/types/teams/team_member_type.rb | 7 +++---- app/models/demand_effort.rb | 8 ++++++++ 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/graphql/types/demand_effort_type.rb b/app/graphql/types/demand_effort_type.rb index 816ad111d..cf3396ae3 100644 --- a/app/graphql/types/demand_effort_type.rb +++ b/app/graphql/types/demand_effort_type.rb @@ -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 diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index f43298191..302dd059a 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -185,6 +185,10 @@ def tasks_list(page_number: 1, limit: 0, title: nil, status: nil, initiative_id: until_date: until_date, portfolio_unit_name: portfolio_unit, task_type: task_type) end + def demand_efforts_list(search_options:) + DemandEffort.order(updated_at: :desc).limit(15) + end + def demands_list(search_options:) demands = base_demands(search_options) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index bc08f4a1d..a8580ab24 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -16,7 +16,7 @@ class TeamMemberType < Types::BaseObject field :user, Types::UserType, null: true field :demand_efforts, [Types::DemandEffortType], null: true - field :latest_deliveries_demands_effort, [Types::DemandType], null: true + field :latest_demand_efforts, [Types::DemandEffortType], null: true field :demands, [Types::DemandType] do argument :limit, Int, required: false @@ -55,9 +55,8 @@ class TeamMemberType < Types::BaseObject end field :project_hours_data, Types::Charts::ProjectHoursChartDataType, null: true - def latest_deliveries_demands_effort - object.demands.order(end_date: :desc).limit(15) - 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' diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index 4114cbbe9..a7eada7bc 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -75,6 +75,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 From a14574d3aadf3b27454a75bd529a34890a9b9712 Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Tue, 26 Sep 2023 16:07:34 -0300 Subject: [PATCH 06/19] feat: add new methods to search demand effort --- app/graphql/types/query_type.rb | 9 +++++++-- app/models/demand_effort.rb | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 302dd059a..96b2dd561 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -34,6 +34,11 @@ class QueryType < Types::BaseObject argument :id, ID end + field :demand_efforts_list Type::DemandEffortList, 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 + field :tasks_list, Types::TasksListType, null: true, description: 'A list of tasks using the arguments as search parameters' do argument :from_date, GraphQL::Types::ISO8601Date, required: false argument :initiative_id, ID, required: false @@ -185,8 +190,8 @@ def tasks_list(page_number: 1, limit: 0, title: nil, status: nil, initiative_id: until_date: until_date, portfolio_unit_name: portfolio_unit, task_type: task_type) end - def demand_efforts_list(search_options:) - DemandEffort.order(updated_at: :desc).limit(15) + def demand_efforts_list(from_date, until_date) + DemandEffort.search_by_date(from_date, until_date) end def demands_list(search_options:) diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index a7eada7bc..81892f47f 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -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('updated_at BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date).order(end_date: :desc).limit(15) } + after_save :update_demand_caches @@ -112,4 +115,8 @@ def management_percentage_value def update_demand_caches DemandEffortService.instance.update_demand_effort_caches(demand) end + + def search_by_date(start_date, end_date) + return DemandEffort.updated_between(start_date, end_date) unless start_date.present? && end_date.present? + end end From 89b10c3c0ab05a13abf0c7d778f0c9ae01b01fff Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Tue, 26 Sep 2023 18:02:58 -0300 Subject: [PATCH 07/19] fix: unresolved graphql error --- app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx index 6704a0764..f9bca846c 100644 --- a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx +++ b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx @@ -8,6 +8,7 @@ import BasicPage from "../../components/BasicPage" import { TeamMember } from "../../modules/teamMember/teamMember.types" import TeamMemberDashboardTables from "../../components/TeamMemberDashboardTables" import TeamMemberDashboardCharts from "../../components/TeamMemberDashboardCharts" +import { FieldValues } from "react-hook-form" const TEAM_MEMBER_QUERY = gql` query TeamMember($id: ID!) { @@ -157,6 +158,7 @@ const TeamMemberDashboard = () => { id: Number(teamMemberId), }, }) + const companySlug = me?.currentCompany?.slug const companyUrl = `/companies/${companySlug}` const teamMemberName = data?.teamMember?.name || "" From 692c5d58c6d75da6ccc7bb119031df6f4eda14cb Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Wed, 27 Sep 2023 14:36:30 -0300 Subject: [PATCH 08/19] Feat: Added variables to query --- app/graphql/types/query_type.rb | 5 --- app/graphql/types/teams/team_member_type.rb | 12 +++++++ app/models/demand_effort.rb | 9 ++--- .../demandEffort/demandEffort.types.ts | 4 +-- .../modules/teamMember/teamMember.types.ts | 1 + .../pages/TeamMembers/TeamMemberDashboard.tsx | 34 +++++++++++++++++-- 6 files changed, 51 insertions(+), 14 deletions(-) diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 96b2dd561..31c1ae931 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -34,11 +34,6 @@ class QueryType < Types::BaseObject argument :id, ID end - field :demand_efforts_list Type::DemandEffortList, 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 - field :tasks_list, Types::TasksListType, null: true, description: 'A list of tasks using the arguments as search parameters' do argument :from_date, GraphQL::Types::ISO8601Date, required: false argument :initiative_id, ID, required: false diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index a8580ab24..2c4b45f78 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -50,12 +50,24 @@ 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:, until_date:) + object + end + def latest_demand_efforts = object.demand_efforts.order(updated_at: :desc).limit(15) + def demands(status: 'ALL', type: 'ALL', limit: nil) diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index 81892f47f..9b9f00c81 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -55,7 +55,7 @@ class DemandEffort < ApplicationRecord 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('updated_at BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date).order(end_date: :desc).limit(15) } + scope :updated_between, ->(start_date, end_date) { where('updated_at BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date) } after_save :update_demand_caches @@ -98,6 +98,10 @@ def effort_money effort_value * demand.project.hour_value end + def search_by_date(start_date, end_date) + return DemandEffort.updated_between(start_date, end_date) unless start_date.present? && end_date.present? + end + private def stage_percentage_value @@ -116,7 +120,4 @@ def update_demand_caches DemandEffortService.instance.update_demand_effort_caches(demand) end - def search_by_date(start_date, end_date) - return DemandEffort.updated_between(start_date, end_date) unless start_date.present? && end_date.present? - end end diff --git a/app/spa/src/modules/demandEffort/demandEffort.types.ts b/app/spa/src/modules/demandEffort/demandEffort.types.ts index d3f4b57db..5780d52fe 100644 --- a/app/spa/src/modules/demandEffort/demandEffort.types.ts +++ b/app/spa/src/modules/demandEffort/demandEffort.types.ts @@ -14,8 +14,8 @@ export type DemandEffort = { stage?: string who?: string memberRole?: string - updatedAt?: Date - createdAt?: Date + updatedAt?: string + createdAt?: string automaticUpdate?: boolean membershipEffortPercentage?: number team?: Team diff --git a/app/spa/src/modules/teamMember/teamMember.types.ts b/app/spa/src/modules/teamMember/teamMember.types.ts index a3d8ba299..f1a5ef798 100644 --- a/app/spa/src/modules/teamMember/teamMember.types.ts +++ b/app/spa/src/modules/teamMember/teamMember.types.ts @@ -27,6 +27,7 @@ export type TeamMember = { demandLargestLeadTime?: Demand latestDeliveries?: Demand[] latestDemandEfforts?: DemandEffort[] + demandEffortsList?: DemandEffort[] demandLeadTimeP80?: number projectsList?: ProjectsList demandBlocksList?: DemandBlocksList diff --git a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx index f9bca846c..f20c707d4 100644 --- a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx +++ b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx @@ -8,10 +8,12 @@ import BasicPage from "../../components/BasicPage" import { TeamMember } from "../../modules/teamMember/teamMember.types" import TeamMemberDashboardTables from "../../components/TeamMemberDashboardTables" import TeamMemberDashboardCharts from "../../components/TeamMemberDashboardCharts" -import { FieldValues } from "react-hook-form" const TEAM_MEMBER_QUERY = gql` - query TeamMember($id: ID!) { + query TeamMember( + $id: ID! + $fromDate: ISO8601Date + $untilDate: ISO8601Date) { teamMember(id: $id) { id name @@ -141,6 +143,31 @@ const TEAM_MEMBER_QUERY = gql` automaticUpdate membershipEffortPercentage } + demandEffortsList(fromDate: $fromDate, untilDate: $untilDate) { + id + effortValue + effortMoney + startTimeToComputation + finishTimeToComputation + stagePercentage + pairingPercentage + managementPercentage + totalBlocked + mainEffortInTransition + stage + who + team { + id + name + } + createdAt + updatedAt + demandId + demandExternalId + memberRole + automaticUpdate + membershipEffortPercentage + } } } ` @@ -156,9 +183,10 @@ const TeamMemberDashboard = () => { const { data, loading } = useQuery(TEAM_MEMBER_QUERY, { variables: { id: Number(teamMemberId), + fromDate: '2023-09-13T13:42:49-03:00', + untilDate: '2023-06-13T13:42:49-03:00', }, }) - const companySlug = me?.currentCompany?.slug const companyUrl = `/companies/${companySlug}` const teamMemberName = data?.teamMember?.name || "" From ee8ad2134e1391f3d4b64a459d059c3cbcfa0e0d Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Wed, 27 Sep 2023 17:32:38 -0300 Subject: [PATCH 09/19] feat: add search form to member effort table --- app/graphql/types/teams/team_member_type.rb | 4 +- app/models/demand_effort.rb | 2 +- .../components/TeamMemberDashboardTables.tsx | 43 ++++++++++++++++++- .../pages/TeamMembers/TeamMemberDashboard.tsx | 28 ++++++++++-- 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index 2c4b45f78..b65b5e5c9 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -57,13 +57,13 @@ class TeamMemberType < Types::BaseObject 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 + 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:, until_date:) - object + object.demand_efforts.updated_between(:from_date, :until_date) end def latest_demand_efforts = object.demand_efforts.order(updated_at: :desc).limit(15) diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index 9b9f00c81..b09fd1865 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -55,7 +55,7 @@ class DemandEffort < ApplicationRecord 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('updated_at BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date) } + scope :updated_between, ->(start_date, end_date) { where('finish_time_to_computation BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date) } after_save :update_demand_caches diff --git a/app/spa/src/components/TeamMemberDashboardTables.tsx b/app/spa/src/components/TeamMemberDashboardTables.tsx index bdc577338..533c1d4a7 100644 --- a/app/spa/src/components/TeamMemberDashboardTables.tsx +++ b/app/spa/src/components/TeamMemberDashboardTables.tsx @@ -1,4 +1,4 @@ -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" @@ -6,15 +6,22 @@ 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() + const demandShortestLeadTime = teamMember.demandShortestLeadTime?.leadtime || 0 const demandLargestLeadTime = teamMember.demandLargestLeadTime?.leadtime || 0 @@ -179,6 +186,40 @@ const TeamMemberDashboardTables = ({ /> +
+ + + + + {t("projectsTable.filter.startDate")} + + + + + + + {t("projectsTable.filter.endDate")} + + + + + + + + + + +
{ const { t } = useTranslation(["teamMembers"]) const { me } = useContext(MeContext) const { teamMemberId } = useParams() + const [searchParams] = useSearchParams() + + const effortsFilters: FieldValues = { + fromDate: searchParams.get("fromDate"), + untilDate: searchParams.get("untilDate"), + } + + const effortsQueryFilters = Object.keys(effortsFilters) + .filter((key) => { + return String(effortsFilters[key]).length > 0 + }) + .reduce>((acc, el) => { + return { ...acc, [el]: effortsFilters[el] } + }, {}) + const { data, loading } = useQuery(TEAM_MEMBER_QUERY, { variables: { id: Number(teamMemberId), - fromDate: '2023-09-13T13:42:49-03:00', - untilDate: '2023-06-13T13:42:49-03:00', + fromDate: effortsQueryFilters.fromDate, + untilDate: effortsQueryFilters.untilDate, }, }) const companySlug = me?.currentCompany?.slug @@ -211,7 +231,7 @@ const TeamMemberDashboard = () => { > {teamMember && ( <> - + )} From b95c44c4a7702f780e7a2e227bfb99febbbcaac2 Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Thu, 28 Sep 2023 14:12:03 -0300 Subject: [PATCH 10/19] Feat: Added search mecanism to memership effort table --- app/graphql/types/teams/team_member_type.rb | 4 ++-- app/spa/src/components/TeamMemberDashboardTables.tsx | 2 +- app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index b65b5e5c9..0f2620fcc 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -62,8 +62,8 @@ class TeamMemberType < Types::BaseObject argument :until_date, GraphQL::Types::ISO8601Date, required: false end - def demand_efforts_list(from_date:, until_date:) - object.demand_efforts.updated_between(:from_date, :until_date) + def demand_efforts_list(from_date: Date.today.ago(1.month), until_date: Date.today) + object.demand_efforts.updated_between(from_date, until_date) end def latest_demand_efforts = object.demand_efforts.order(updated_at: :desc).limit(15) diff --git a/app/spa/src/components/TeamMemberDashboardTables.tsx b/app/spa/src/components/TeamMemberDashboardTables.tsx index 533c1d4a7..a186bd651 100644 --- a/app/spa/src/components/TeamMemberDashboardTables.tsx +++ b/app/spa/src/components/TeamMemberDashboardTables.tsx @@ -120,7 +120,7 @@ const TeamMemberDashboardTables = ({ ] const latestEffortsRows = - teamMember?.latestDemandEfforts?.map((effort) => [ + teamMember?.demandEffortsList?.map((effort) => [ `${(effort.who || "")}`, { return { ...acc, [el]: effortsFilters[el] } }, {}) + const a = new Date('Tue, 29 Aug 2023 01:46:22 -0300') + const b = new Date('Wed, 13 Sep 2023 14:24:57 -0300') + const { data, loading } = useQuery(TEAM_MEMBER_QUERY, { variables: { id: Number(teamMemberId), + // fromDate: a, + // untilDate: b, fromDate: effortsQueryFilters.fromDate, untilDate: effortsQueryFilters.untilDate, + // fromDate: 'Wed, 13 Sep 2023 14:24:57.574000000 -03 -03:00', + // untilDate: 'Wed, 13 Sep 2023 14:24:57.574000000 -03 -03:00' }, }) const companySlug = me?.currentCompany?.slug From 6f9a2bda799ba5ca689733718686f372b6d1bed5 Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Thu, 28 Sep 2023 15:27:13 -0300 Subject: [PATCH 11/19] test: add new tests and remove unnecessary lines --- app/graphql/types/query_type.rb | 4 ---- app/models/demand_effort.rb | 4 ---- spec/models/demand_effort_spec.rb | 34 +++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index 31c1ae931..f43298191 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -185,10 +185,6 @@ def tasks_list(page_number: 1, limit: 0, title: nil, status: nil, initiative_id: until_date: until_date, portfolio_unit_name: portfolio_unit, task_type: task_type) end - def demand_efforts_list(from_date, until_date) - DemandEffort.search_by_date(from_date, until_date) - end - def demands_list(search_options:) demands = base_demands(search_options) diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index b09fd1865..d573fec6f 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -97,10 +97,6 @@ def member_role def effort_money effort_value * demand.project.hour_value end - - def search_by_date(start_date, end_date) - return DemandEffort.updated_between(start_date, end_date) unless start_date.present? && end_date.present? - end private diff --git a/spec/models/demand_effort_spec.rb b/spec/models/demand_effort_spec.rb index 45b7c4ad9..9b85abe9e 100644 --- a/spec/models/demand_effort_spec.rb +++ b/spec/models/demand_effort_spec.rb @@ -119,4 +119,38 @@ expect(effort.who).to eq 'foo do bar' end end + + describe '#demand_external_id' do + it 'returns the demand extrenal id assigned' do + team_member = Fabricate :team_member, name: 'foo do bar' + membership = Fabricate :membership, team_member: team_member + demand = Fabricate :demand, external_id: 'lambda-10' + item_assignment = Fabricate :item_assignment, membership: membership, demand: demand + effort = Fabricate :demand_effort, item_assignment: item_assignment + + expect(effort.demand_external_id).to eq 'lambda-10' + end + end + + describe '#team' do + it 'returns the team assigned' do + team_member = Fabricate :team_member, name: 'foo do bar' + membership = Fabricate :membership, team_member: team_member + item_assignment = Fabricate :item_assignment, membership: membership + effort = Fabricate :demand_effort, item_assignment: item_assignment + + expect(effort.team.name).to eq effort.team.name + end + end + + describe '#member_role' do + it 'returns the member role assigned' do + team_member = Fabricate :team_member, name: 'foo do bar' + membership = Fabricate :membership, team_member: team_member + item_assignment = Fabricate :item_assignment, membership: membership + effort = Fabricate :demand_effort, item_assignment: item_assignment + + expect(effort.member_role).to eq 'developer' + end + end end From 926cacefa1a335b3c616557825ccffda9e0f7da5 Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Thu, 28 Sep 2023 18:44:07 -0300 Subject: [PATCH 12/19] feat: Added incomplete test --- app/graphql/types/teams/team_member_type.rb | 8 +++++++- app/models/demand_effort.rb | 6 +++++- app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx | 7 ------- spec/graphql/types/query_type_spec.rb | 9 +++++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index 0f2620fcc..48c4dffe9 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -63,7 +63,13 @@ class TeamMemberType < Types::BaseObject end def demand_efforts_list(from_date: Date.today.ago(1.month), until_date: Date.today) - object.demand_efforts.updated_between(from_date, until_date) + if from_date.nil? && until_date.nil? + object.demand_efforts.updated_between(Date.today.ago(1.month), Date.today) + else + near_date = [from_date, until_date].max + far_date = [from_date, until_date].min + object.demand_efforts.updated_between(far_date, near_date) + end end def latest_demand_efforts = object.demand_efforts.order(updated_at: :desc).limit(15) diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index d573fec6f..69c3840a7 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -55,7 +55,7 @@ class DemandEffort < ApplicationRecord 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('finish_time_to_computation BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date) } + scope :updated_between, ->(start_date, end_date) { where('finish_time_to_computation 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 @@ -98,6 +98,10 @@ def effort_money effort_value * demand.project.hour_value end + def search_by_date(start_date, end_date) + return DemandEffort.updated_between(start_date, end_date) unless start_date.present? && end_date.present? + end + private def stage_percentage_value diff --git a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx index 15fe25c99..9f4979200 100644 --- a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx +++ b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx @@ -200,18 +200,11 @@ const TeamMemberDashboard = () => { return { ...acc, [el]: effortsFilters[el] } }, {}) - const a = new Date('Tue, 29 Aug 2023 01:46:22 -0300') - const b = new Date('Wed, 13 Sep 2023 14:24:57 -0300') - const { data, loading } = useQuery(TEAM_MEMBER_QUERY, { variables: { id: Number(teamMemberId), - // fromDate: a, - // untilDate: b, fromDate: effortsQueryFilters.fromDate, untilDate: effortsQueryFilters.untilDate, - // fromDate: 'Wed, 13 Sep 2023 14:24:57.574000000 -03 -03:00', - // untilDate: 'Wed, 13 Sep 2023 14:24:57.574000000 -03 -03:00' }, }) const companySlug = me?.currentCompany?.slug diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index 6d651ef7e..ab3eb2ab4 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -1753,6 +1753,8 @@ other_demand_finished = Fabricate :demand, team: team, project: other_project, created_date: 3.days.ago, commitment_date: 6.hours.ago, end_date: 2.hours.ago, work_item_type: bug_type bug = Fabricate :demand, team: team, project: project, created_date: 2.days.ago, end_date: nil, work_item_type: bug_type other_bug = Fabricate :demand, team: team, project: project, created_date: 1.day.ago, end_date: nil, work_item_type: bug_type + demand_effort = Fabricate :demand_effort, demand: demand_finished, start_time_to_computation: 1.day.ago, finish_time_to_computation: 20.days.ago, effort_value: 70 + first_assignmen = Fabricate :item_assignment, membership: membership, demand: demand_finished @@ -1779,7 +1781,6 @@ Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 1.day.ago, effort_value: 20 Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 2.days.from_now, effort_value: 100 Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 2.days.from_now, effort_value: 70 - Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 2.months.ago, effort_value: 100 query = @@ -1891,6 +1892,9 @@ yAxisHours } memberThroughputData(numberOfWeeks: 3) + demandEffortsList{ + finishTimeToComputation + } } }) @@ -2040,7 +2044,8 @@ 'yAxisProjectsNames' => [project.name] }, - 'memberThroughputData' => [0, 0, 0, 2] + 'memberThroughputData' => [0, 0, 0, 2] , + 'demandEffortsList' => [] }) end end From 09e2aee38a9b9a05d9b67891e54a04fc3143d8ca Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Fri, 29 Sep 2023 17:25:52 -0300 Subject: [PATCH 13/19] feat: Added date search to latest efforts table --- app/graphql/types/teams/team_member_type.rb | 4 ++-- .../components/TeamMemberDashboardTables.tsx | 17 +++++++++++++---- app/spa/src/locales/coca/teamMembers.json | 4 +++- app/spa/src/locales/en/teamMembers.json | 4 +++- app/spa/src/locales/pt/teamMembers.json | 4 +++- .../pages/TeamMembers/TeamMemberDashboard.tsx | 14 +++++--------- spec/graphql/types/query_type_spec.rb | 6 +++--- 7 files changed, 32 insertions(+), 21 deletions(-) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index 48c4dffe9..751746e0d 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -62,8 +62,8 @@ class TeamMemberType < Types::BaseObject argument :until_date, GraphQL::Types::ISO8601Date, required: false end - def demand_efforts_list(from_date: Date.today.ago(1.month), until_date: Date.today) - if from_date.nil? && until_date.nil? + def demand_efforts_list(from_date: nil , until_date: nil ) + if from_date.blank? && until_date.blank? object.demand_efforts.updated_between(Date.today.ago(1.month), Date.today) else near_date = [from_date, until_date].max diff --git a/app/spa/src/components/TeamMemberDashboardTables.tsx b/app/spa/src/components/TeamMemberDashboardTables.tsx index a186bd651..8c302caf9 100644 --- a/app/spa/src/components/TeamMemberDashboardTables.tsx +++ b/app/spa/src/components/TeamMemberDashboardTables.tsx @@ -22,6 +22,14 @@ const TeamMemberDashboardTables = ({ 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 @@ -95,6 +103,7 @@ const TeamMemberDashboardTables = ({ t("dashboard.demandBlocks.blockTime"), t("dashboard.demandBlocks.unblockTime"), ] + const demandBlocksRows = teamMember.demandBlocksList?.demandBlocks?.map((block) => [ block.demand?.demandTitle || "", @@ -190,8 +199,8 @@ const TeamMemberDashboardTables = ({ - - {t("projectsTable.filter.startDate")} + + {t("dashboard.latestEfforts.fromDate")} - - {t("projectsTable.filter.endDate")} + + {t("dashboard.latestEfforts.untilDate")} { const { t } = useTranslation(["teamMembers"]) const { me } = useContext(MeContext) @@ -231,7 +224,10 @@ const TeamMemberDashboard = () => { > {teamMember && ( <> - + )} diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index ab3eb2ab4..c7d03c22f 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -1886,15 +1886,15 @@ xAxis yAxis } + demandEffortsList{ + finishTimeToComputation + } projectHoursData { xAxis yAxisProjectsNames yAxisHours } memberThroughputData(numberOfWeeks: 3) - demandEffortsList{ - finishTimeToComputation - } } }) From 77ef112ee42ab9d3ff919a0fbb8525e0fc9ab804 Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Fri, 29 Sep 2023 17:39:35 -0300 Subject: [PATCH 14/19] fix: remove unnecessary method --- app/models/demand_effort.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index 69c3840a7..b4432bb42 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -55,7 +55,7 @@ class DemandEffort < ApplicationRecord 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('finish_time_to_computation BETWEEN :start_date AND :end_date', start_date: start_date, end_date: end_date).order(finish_time_to_computation: :desc) } + 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 @@ -99,8 +99,6 @@ def effort_money end def search_by_date(start_date, end_date) - return DemandEffort.updated_between(start_date, end_date) unless start_date.present? && end_date.present? - end private From e1da9d1a6f206b7249c0e172d14fce254374aba7 Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Fri, 29 Sep 2023 17:47:29 -0300 Subject: [PATCH 15/19] fix: remove unnecessary line --- app/models/demand_effort.rb | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/models/demand_effort.rb b/app/models/demand_effort.rb index b4432bb42..ee1152363 100644 --- a/app/models/demand_effort.rb +++ b/app/models/demand_effort.rb @@ -98,8 +98,6 @@ def effort_money effort_value * demand.project.hour_value end - def search_by_date(start_date, end_date) - private def stage_percentage_value From aa499d2d57fb10b725944ccd6c979a94eebae997 Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Thu, 28 Sep 2023 16:42:03 -0300 Subject: [PATCH 16/19] feat: remove pagination demand block --- app/controllers/demand_blocks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/demand_blocks_controller.rb b/app/controllers/demand_blocks_controller.rb index 58b0e4699..18652df42 100644 --- a/app/controllers/demand_blocks_controller.rb +++ b/app/controllers/demand_blocks_controller.rb @@ -61,7 +61,7 @@ def search @demand_blocks = build_project_query(@demand_blocks) @demand_blocks = build_ordering_query(@demand_blocks) - @paged_demand_blocks = @demand_blocks.page(page_param) + @paged_demand_blocks = @demand_blocks.page(page_param).per(100) demands_count render 'demand_blocks/index' From 5d5f5c9bdd95ff92a6a7619cbef1a370ac6324dd Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Thu, 28 Sep 2023 17:03:13 -0300 Subject: [PATCH 17/19] fix: add new lines to demand block pagination --- app/controllers/demand_blocks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/demand_blocks_controller.rb b/app/controllers/demand_blocks_controller.rb index 18652df42..5bedf2b2c 100644 --- a/app/controllers/demand_blocks_controller.rb +++ b/app/controllers/demand_blocks_controller.rb @@ -61,7 +61,7 @@ def search @demand_blocks = build_project_query(@demand_blocks) @demand_blocks = build_ordering_query(@demand_blocks) - @paged_demand_blocks = @demand_blocks.page(page_param).per(100) + @paged_demand_blocks = @demand_blocks.page(page_param).per(1000) demands_count render 'demand_blocks/index' From f42b176cb20b477b1a14cdbe845359e1af573390 Mon Sep 17 00:00:00 2001 From: Danilo Gomes Date: Thu, 28 Sep 2023 17:06:20 -0300 Subject: [PATCH 18/19] fix: add more lines to demand block pagination --- app/controllers/demand_blocks_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/demand_blocks_controller.rb b/app/controllers/demand_blocks_controller.rb index 5bedf2b2c..3433ab2c8 100644 --- a/app/controllers/demand_blocks_controller.rb +++ b/app/controllers/demand_blocks_controller.rb @@ -19,7 +19,7 @@ def deactivate def index @demand_blocks_ids = @company.demand_blocks.unscoped.map(&:id) @demand_blocks = @company.demand_blocks.for_active_projects.active.order(block_time: :desc) - @paged_demand_blocks = @demand_blocks.page(page_param) + @paged_demand_blocks = @demand_blocks.page(page_param).per(1000) demands_count end From 318d445e84f8da78efe58caa5541ec229788801a Mon Sep 17 00:00:00 2001 From: JoaoTaller Date: Fri, 29 Sep 2023 19:25:08 -0300 Subject: [PATCH 19/19] fix: setted default values in backend --- app/graphql/types/teams/team_member_type.rb | 10 ++-------- .../pages/TeamMembers/TeamMemberDashboard.tsx | 5 ++++- spec/graphql/types/query_type_spec.rb | 17 +++++++++-------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/graphql/types/teams/team_member_type.rb b/app/graphql/types/teams/team_member_type.rb index 751746e0d..90f26a3df 100644 --- a/app/graphql/types/teams/team_member_type.rb +++ b/app/graphql/types/teams/team_member_type.rb @@ -62,14 +62,8 @@ class TeamMemberType < Types::BaseObject argument :until_date, GraphQL::Types::ISO8601Date, required: false end - def demand_efforts_list(from_date: nil , until_date: nil ) - if from_date.blank? && until_date.blank? - object.demand_efforts.updated_between(Date.today.ago(1.month), Date.today) - else - near_date = [from_date, until_date].max - far_date = [from_date, until_date].min - object.demand_efforts.updated_between(far_date, near_date) - 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) diff --git a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx index b84fbe727..b01059a24 100644 --- a/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx +++ b/app/spa/src/pages/TeamMembers/TeamMemberDashboard.tsx @@ -11,7 +11,7 @@ import TeamMemberDashboardCharts from "../../components/TeamMemberDashboardChart import { FieldValues } from "react-hook-form" const TEAM_MEMBER_QUERY = gql` - query TeamMember($id: ID!, $fromDate: ISO8601Date, $untilDate: ISO8601Date) { + query TeamMember($id: ID!, $fromDate: ISO8601Date, $untilDate: ISO8601Date ) { teamMember(id: $id) { id name @@ -180,6 +180,9 @@ const TeamMemberDashboard = () => { const { teamMemberId } = useParams() const [searchParams] = useSearchParams() + const today = new Date() + const monthAgo = new Date(new Date().setDate(new Date().getDate() - 30)) + const effortsFilters: FieldValues = { fromDate: searchParams.get("fromDate"), untilDate: searchParams.get("untilDate"), diff --git a/spec/graphql/types/query_type_spec.rb b/spec/graphql/types/query_type_spec.rb index c7d03c22f..140936ae5 100644 --- a/spec/graphql/types/query_type_spec.rb +++ b/spec/graphql/types/query_type_spec.rb @@ -1753,11 +1753,10 @@ other_demand_finished = Fabricate :demand, team: team, project: other_project, created_date: 3.days.ago, commitment_date: 6.hours.ago, end_date: 2.hours.ago, work_item_type: bug_type bug = Fabricate :demand, team: team, project: project, created_date: 2.days.ago, end_date: nil, work_item_type: bug_type other_bug = Fabricate :demand, team: team, project: project, created_date: 1.day.ago, end_date: nil, work_item_type: bug_type - demand_effort = Fabricate :demand_effort, demand: demand_finished, start_time_to_computation: 1.day.ago, finish_time_to_computation: 20.days.ago, effort_value: 70 - - + + first_assignmen = Fabricate :item_assignment, membership: membership, demand: demand_finished - + another_team_member_assignmen_that_should_not_appear = Fabricate :item_assignment, membership: another_membership, demand: demand_finished Fabricate :item_assignment, membership: membership, demand: other_demand_finished @@ -1777,7 +1776,7 @@ Fabricate :demand_effort, demand: demand_finished, item_assignment: another_team_member_assignmen_that_should_not_appear, start_time_to_computation: 2.days.ago, effort_value: 10_000 - Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 1.day.ago, effort_value: 100 + Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 1.day.ago, finish_time_to_computation: 20.days.ago, effort_value: 100 Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 1.day.ago, effort_value: 20 Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 2.days.from_now, effort_value: 100 Fabricate :demand_effort, demand: demand_finished, item_assignment: first_assignmen, start_time_to_computation: 2.days.from_now, effort_value: 70 @@ -1886,7 +1885,7 @@ xAxis yAxis } - demandEffortsList{ + demandEffortsList(fromDate: "#{25.days.ago.iso8601}", untilDate: "#{15.days.ago.iso8601}"){ finishTimeToComputation } projectHoursData { @@ -1907,7 +1906,7 @@ lead_time_p65 = Stats::StatisticsService.instance.percentile(65, team_member.demands.finished_with_leadtime.order(:end_date).map { |demand| demand.leadtime.to_f }) lead_time_p80 = Stats::StatisticsService.instance.percentile(80, team_member.demands.finished_with_leadtime.order(:end_date).map { |demand| demand.leadtime.to_f }) lead_time_p95 = Stats::StatisticsService.instance.percentile(95, team_member.demands.finished_with_leadtime.order(:end_date).map { |demand| demand.leadtime.to_f }) - + result = FlowClimateSchema.execute(query, variables: nil, context: context).as_json expect(result.dig('data', 'me')).to eq({ 'id' => user.id.to_s, @@ -2045,7 +2044,9 @@ }, 'memberThroughputData' => [0, 0, 0, 2] , - 'demandEffortsList' => [] + 'demandEffortsList' => [{ + 'finishTimeToComputation' => 20.days.ago.iso8601 + }] }) end end