Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/fix time entries analytics #190

Merged
merged 2 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# id :bigint not null, primary key
# coverage :float
# end_date :date
# start_date :date
# end_date :datetime
# start_date :datetime
# created_at :datetime not null
# updated_at :datetime not null
# requirement_id :bigint not null
Expand Down
4 changes: 2 additions & 2 deletions app/models/requirement.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# id :bigint not null, primary key
# coverage :float
# end_date :date
# start_date :date
# end_date :datetime
# start_date :datetime
# created_at :datetime not null
# updated_at :datetime not null
# profession_id :bigint not null
Expand Down
8 changes: 6 additions & 2 deletions app/utils/analytics/time_entries/expected_hours.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@ def data
end

def entries
days = ([@start_date, @assignment.start_date].max..[@end_date, @assignment.end_date].min).filter do |d|
!d.sunday? && !d.saturday?
start_date = [@start_date, @assignment.start_date].max
end_date = [@end_date, @assignment.end_date].min

# Convert the range into an array of dates
days = (start_date.to_date..end_date.to_date).to_a.select do |d|
d.wday.between?(1, 5) # Exclude Saturday (6) and Sunday (0)
end

days.map do |day|
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class ChangeDateToDateTimeInRequirements < ActiveRecord::Migration[7.0]
def up
change_column :requirements, :end_date, :datetime
change_column :requirements, :start_date, :datetime
end

def down
change_column :requirements, :end_date, :date
change_column :requirements, :start_date, :date
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

class ChangeDateToDateTimeInAssignments < ActiveRecord::Migration[7.0]
def up
change_column :assignments, :end_date, :datetime
change_column :assignments, :start_date, :datetime
end

def down
change_column :assignments, :end_date, :date
change_column :assignments, :start_date, :date
end
end
10 changes: 5 additions & 5 deletions db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions spec/factories/assignments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# id :bigint not null, primary key
# coverage :float
# end_date :date
# start_date :date
# end_date :datetime
# start_date :datetime
# created_at :datetime not null
# updated_at :datetime not null
# requirement_id :bigint not null
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/requirements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# id :bigint not null, primary key
# coverage :float
# end_date :date
# start_date :date
# end_date :datetime
# start_date :datetime
# created_at :datetime not null
# updated_at :datetime not null
# profession_id :bigint not null
Expand Down
4 changes: 2 additions & 2 deletions spec/models/assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# id :bigint not null, primary key
# coverage :float
# end_date :date
# start_date :date
# end_date :datetime
# start_date :datetime
# created_at :datetime not null
# updated_at :datetime not null
# requirement_id :bigint not null
Expand Down
4 changes: 2 additions & 2 deletions spec/models/requirement_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#
# id :bigint not null, primary key
# coverage :float
# end_date :date
# start_date :date
# end_date :datetime
# start_date :datetime
# created_at :datetime not null
# updated_at :datetime not null
# profession_id :bigint not null
Expand Down
Loading