mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-17 11:54:22 +01:00
(bug) invalid duration for machine/spaces reservations in statistics, when using slots of not 1 hour
This commit is contained in:
parent
6e9cfe11c3
commit
2756502131
@ -1,5 +1,8 @@
|
||||
# Changelog Fab-manager
|
||||
|
||||
- Fix a bug: invalid duration for machine/spaces reservations in statistics, when using slots of not 1 hour
|
||||
- [TODO DEPLOY] `rails fablab:es:build_stats` THEN `rails fablab:maintenance:regenerate_statistics[2014,1]`
|
||||
|
||||
## v6.0.5 2023 May 2
|
||||
|
||||
- Fix a bug: unable to show calendar for Firefox and Safari
|
||||
|
@ -41,7 +41,7 @@ module ExcelHelper
|
||||
unless type.simple
|
||||
data.push hit['_source']['stat']
|
||||
styles.push nil
|
||||
types.push :string
|
||||
types.push :float
|
||||
end
|
||||
|
||||
[data, styles, types]
|
||||
|
@ -8,7 +8,7 @@ module StatConcern
|
||||
attribute :type, String
|
||||
attribute :subType, String
|
||||
attribute :date, String
|
||||
attribute :stat, Integer
|
||||
attribute :stat, Float
|
||||
attribute :userId, Integer
|
||||
attribute :gender, String
|
||||
attribute :age, Integer
|
||||
|
@ -39,11 +39,11 @@ module Statistics::Concerns::HelpersConcern
|
||||
|
||||
def difference_in_hours(start_at, end_at)
|
||||
if start_at.to_date == end_at.to_date
|
||||
((end_at - start_at) / 3600.0).to_i
|
||||
((end_at - start_at) / 3600.0).to_f
|
||||
else
|
||||
end_at_to_start_date = end_at.change(year: start_at.year, month: start_at.month, day: start_at.day)
|
||||
hours = ((end_at_to_start_date - start_at) / 60 / 60).to_i
|
||||
hours = ((end_at.to_date - start_at.to_date).to_i + 1) * hours if end_at.to_date > start_at.to_date
|
||||
hours = ((end_at_to_start_date - start_at) / 60 / 60).to_f
|
||||
hours = ((end_at.to_date - start_at.to_date).to_f + 1) * hours if end_at.to_date > start_at.to_date
|
||||
hours
|
||||
end
|
||||
end
|
||||
|
@ -57,7 +57,7 @@ class Statistics::FetcherService
|
||||
machine_type: r.reservable.friendly_id,
|
||||
machine_name: r.reservable.name,
|
||||
slot_dates: r.slots.map(&:start_at).map(&:to_date),
|
||||
nb_hours: (r.slots.map(&:duration).map(&:to_i).reduce(:+) / 3600.0).to_i,
|
||||
nb_hours: (r.slots.map(&:duration).map(&:to_i).reduce(:+) / 3600.0).to_f,
|
||||
ca: calcul_ca(r.original_invoice) }.merge(user_info(profile))
|
||||
yield result
|
||||
end
|
||||
@ -81,7 +81,7 @@ class Statistics::FetcherService
|
||||
space_name: r.reservable.name,
|
||||
space_type: r.reservable.slug,
|
||||
slot_dates: r.slots.map(&:start_at).map(&:to_date),
|
||||
nb_hours: (r.slots.map(&:duration).map(&:to_i).reduce(:+) / 3600.0).to_i,
|
||||
nb_hours: (r.slots.map(&:duration).map(&:to_i).reduce(:+) / 3600.0).to_f,
|
||||
ca: calcul_ca(r.original_invoice) }.merge(user_info(profile))
|
||||
yield result
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user