Skip to content

Commit

Permalink
feat: add membership effort - FC-950
Browse files Browse the repository at this point in the history
  • Loading branch information
danilogomes committed Sep 21, 2023
1 parent 244fe09 commit f09f5a2
Show file tree
Hide file tree
Showing 19 changed files with 1,058 additions and 360 deletions.
5 changes: 3 additions & 2 deletions app/graphql/mutations/save_membership_mutation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module Mutations
class SaveMembershipMutation < Mutations::BaseMutation
argument :end_date, String, required: false
argument :hours_per_month, Integer, required: true
argument :effort_percentage, Float, required: true
argument :member_role, Integer, required: true
argument :membership_id, ID, required: true
argument :start_date, String, required: true
Expand All @@ -12,12 +13,12 @@ class SaveMembershipMutation < Mutations::BaseMutation
field :message, String
field :status_message, Types::UpdateResponses, null: false

def resolve(membership_id:, member_role:, hours_per_month:, start_date:, end_date:)
def resolve(membership_id:, member_role:, hours_per_month:, effort_percentage:, start_date:, end_date:)
membership = Membership.find_by(id: membership_id)

if membership.present?
History::MembershipAvailableHoursHistory.create(membership_id: membership_id, available_hours: hours_per_month)
membership.update(member_role: member_role, hours_per_month: hours_per_month, start_date: start_date, end_date: end_date)
membership.update(member_role: member_role, hours_per_month: hours_per_month, effort_percentage: effort_percentage, start_date: start_date, end_date: end_date)
{ status_message: 'SUCCESS', membership: membership, message: 'Membership updated.' }
else
{ status_message: 'NOT_FOUND', membership: nil, message: "Membership not found with ID ##{membership_id}" }
Expand Down
1 change: 1 addition & 0 deletions app/graphql/types/demand_effort_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ class DemandEffortType < Types::BaseObject
field :total_blocked, Float, null: false
field :updated_at, GraphQL::Types::ISO8601DateTime, null: false
field :who, String, null: true
field :membership_effort_percentage, Float, null: true
end
end
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 :end_date, GraphQL::Types::ISO8601Date
field :hours_per_month, Integer
field :effort_percentage, Float
field :id, ID, null: false
field :member_role, Integer, null: false
field :member_role_description, String, null: false
Expand Down
8 changes: 5 additions & 3 deletions app/services/demand_effort_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,18 @@ def compute_and_save_effort(day_to_effort, assignment, top_effort_assignment, tr
pairing_percentage = transition.stage_pairing_percentage_to_project

management_percentage = transition.stage_management_percentage_to_project

membership_effort_percentage = membership.effort_percentage.nil? ? 100.0 : membership.effort_percentage

effort_total = effort_by_dates * (management_percentage + 1) * stage_percentage
effort_total = (effort_by_dates * (management_percentage + 1) * stage_percentage * membership_effort_percentage)/100

effort_total *= pairing_percentage unless main_assignment

effort_total = remove_member_previous_efforts_in_demand(assignment, demand, demand_effort, effort_start_time, effort_total)

demand_effort.update(effort_value: effort_total, stage_percentage: stage_percentage,
management_percentage: management_percentage, pairing_percentage: pairing_percentage, main_effort_in_transition: main_assignment,
start_time_to_computation: effort_start_time, finish_time_to_computation: effort_end_time)
start_time_to_computation: effort_start_time, finish_time_to_computation: effort_end_time, membership_effort_percentage: membership_effort_percentage)

demand_effort.id
end
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/locales/coca/demandEffort.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"finishTimeToComputation": "End of Data",
"stagePercentage": "% Stage",
"pairingPercentage": "% Pair",
"membershipEffortPercentage": "% Membership",
"managementPercentage": "% Management",
"totalBlocked": "Blocked Time",
"mainEffortInTransition": "Main Effort?",
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/locales/coca/membership.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"startDate": "Start",
"endDate": "End",
"hoursPerMonth": "Hours per Month",
"effortPercentage": "Effort Percentage",
"options": {
"memberRole": {
"developer": "Developer",
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/locales/en/demandEffort.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"finishTimeToComputation": "End of Data",
"stagePercentage": "% Stage",
"pairingPercentage": "% Pair",
"membershipEffortPercentage": "% Membership",
"managementPercentage": "% Management",
"totalBlocked": "Blocked Time",
"mainEffortInTransition": "Main Effort?",
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/locales/en/membership.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"startDate": "Start",
"endDate": "End",
"hoursPerMonth": "Hours per Month",
"effortPercentage": "Effort Percentage",
"options": {
"memberRole": {
"developer": "Developer",
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/locales/pt/demandEffort.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"finishTimeToComputation": "Fim dos Dados",
"stagePercentage": "% Etapa",
"pairingPercentage": "% Par",
"membershipEffortPercentage": "% Membro",
"managementPercentage": "% Gestão",
"totalBlocked": "Tempo Bloqueado",
"mainEffortInTransition": "Principal?",
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/locales/pt/membership.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"startDate": "Início",
"endDate": "Fim",
"hoursPerMonth": "Horas por mês",
"effortPercentage": "Porcentagem de Esforço",
"options": {
"memberRole": {
"developer": "Desenvolvedor",
Expand Down
1 change: 1 addition & 0 deletions app/spa/src/modules/demandEffort/demandEffort.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export type DemandEffort = {
who?: string
memberRole?: string
automaticUpdate?: boolean
membershipEffortPercentage?: number
}
1 change: 1 addition & 0 deletions app/spa/src/modules/team/team.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export type Membership = {
team: Team
teamMemberName?: string
hoursPerMonth?: number
effortPercentage?: number
startDate?: string
endDate?: string
memberRole?: number
Expand Down
9 changes: 6 additions & 3 deletions app/spa/src/pages/Demand/DemandEfforts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const DEMAND_QUERY = gql`
who
memberRole
automaticUpdate
membershipEffortPercentage
}
}
}
Expand Down Expand Up @@ -68,6 +69,7 @@ const DemandEfforts = () => {
t("table.header.stagePercentage"),
t("table.header.pairingPercentage"),
t("table.header.managementPercentage"),
t("table.header.membershipEffortPercentage"),
t("table.header.totalBlocked"),
t("table.header.mainEffortInTransition"),
t("table.header.automaticUpdate"),
Expand All @@ -91,9 +93,10 @@ const DemandEfforts = () => {
) : (
""
),
(Number(effort.stagePercentage || 0) * 100).toFixed(2) || 0,
(Number(effort.pairingPercentage || 0) * 100).toFixed(2) || 0,
(Number(effort.managementPercentage || 0) * 100).toFixed(2) || 0,
(Number(effort.stagePercentage || 0) * 100).toFixed(2),
(Number(effort.pairingPercentage || 0) * 100).toFixed(2),
(Number(effort.managementPercentage || 0) * 100).toFixed(2),
(Number(effort.membershipEffortPercentage || 0)).toFixed(2),
effort.totalBlocked || 0,
effort.mainEffortInTransition ? <CheckIcon color="primary" /> : "",
effort.automaticUpdate ? <CheckIcon color="primary" /> : "",
Expand Down
16 changes: 16 additions & 0 deletions app/spa/src/pages/Teams/MembershipForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,21 @@ const MembershipForm = () => {
$endDate: String
$startDate: String!
$hoursPerMonth: Int!
$effortPercentage: Float!
) {
saveMembership(
membershipId: $membershipId
memberRole: $memberRole
endDate: $endDate
startDate: $startDate
hoursPerMonth: $hoursPerMonth
effortPercentage: $effortPercentage
) {
membership {
id
teamMemberName
hoursPerMonth
effortPercentage
startDate
endDate
memberRole
Expand Down Expand Up @@ -81,6 +84,7 @@ const MembershipForm = () => {
variables: {
memberRole: Number(data.memberRole),
hoursPerMonth: Number(data.hoursPerMonth),
effortPercentage: Number(data.effortPercentage),
startDate: data.startDate,
endDate: data.endDate,
membershipId: membershipId,
Expand Down Expand Up @@ -126,6 +130,17 @@ const MembershipForm = () => {
{...register("hoursPerMonth", { required: true })}
/>
</FormControl>
<FormControl sx={{ marginBottom: 4 }}>
<InputLabel htmlFor="effortPercentage">
{t("fields.effortPercentage")}
</InputLabel>

<Input
defaultValue={membership?.effortPercentage}
type="number"
{...register("effortPercentage", { required: true })}
/>
</FormControl>
<FormControl sx={{ marginBottom: 4 }}>
<InputLabel
shrink
Expand Down Expand Up @@ -181,6 +196,7 @@ const MEMBERSHIP_FORM_QUERY = gql`
startDate
endDate
hoursPerMonth
effortPercentage
team {
id
name
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddEffortPercentageToMembership < ActiveRecord::Migration[7.0]
def change
add_column :memberships, :effort_percentage, :decimal
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMembershipEffortPercentageToDemandEffort < ActiveRecord::Migration[7.0]
def change
add_column :demand_efforts, :membership_effort_percentage, :decimal
end
end
Loading

0 comments on commit f09f5a2

Please sign in to comment.