Skip to content

Commit

Permalink
fix: remove method remove_duplications_effort
Browse files Browse the repository at this point in the history
  • Loading branch information
danilogomes committed Sep 18, 2023
1 parent 0561382 commit 244fe09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
13 changes: 0 additions & 13 deletions app/services/demand_effort_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ def compute_and_save_effort(day_to_effort, assignment, top_effort_assignment, tr
effort_start_time = [start_time, day_to_effort.beginning_of_day.change(hour: 8, minute: 0, second: 0)].max
effort_end_time = [assignment.finish_time, transition.last_time_out, demand.discarded_at, day_to_effort.end_of_day.change(hour: 20, minute: 0, second: 0), Time.zone.now].compact.min

remove_duplications_effort(demand, effort_start_time, transition)

demand_effort = demand
.demand_efforts
.where(demand_transition: transition, item_assignment: assignment)
Expand Down Expand Up @@ -119,17 +117,6 @@ def compute_and_save_effort(day_to_effort, assignment, top_effort_assignment, tr
demand_effort.id
end

def remove_duplications_effort(demand, effort_start_time, transition)
demand_efforts = demand
.demand_efforts
.where(demand_transition: transition)
.where('start_time_to_computation BETWEEN :start_time AND :end_time',
start_time: effort_start_time.beginning_of_day,
end_time: effort_start_time.end_of_day)

demand_efforts.map(&:destroy) if demand_efforts.count > 1
end

def remove_member_previous_efforts_in_demand(assignment, demand, demand_effort, effort_start_time, effort_total)
previous_efforts_to_day = demand
.demand_efforts
Expand Down
4 changes: 2 additions & 2 deletions spec/services/demand_effort_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@
described_class.instance.build_efforts_to_demand(demand)
described_class.instance.build_efforts_to_demand(other_project_demand)

expect(demand.demand_efforts.all.map { |effort| effort.effort_value.to_f }).to match_array [2.5, 3.54]
expect(demand.demand_efforts.sum(&:effort_value).to_f).to eq 6.04
expect(demand.demand_efforts.all.map { |effort| effort.effort_value.to_f }).to match_array [6.88, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 3.659999999999999, 3.54, 2.5]
expect(demand.demand_efforts.sum(&:effort_value).to_f).to eq 20.18

expect(other_project_demand.demand_efforts.all.map { |effort| effort.effort_value.to_f }).to eq [1.96, 1.96]
expect(other_project_demand.demand_efforts.sum(&:effort_value).to_f).to eq 3.92
Expand Down

0 comments on commit 244fe09

Please sign in to comment.