mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-30 19:52:20 +01:00
(bug) no statistics on trainings and spaces reservations
This commit is contained in:
parent
fdac8168ef
commit
873752172d
@ -3,6 +3,7 @@
|
||||
- Allow searching by username (#401)
|
||||
- Fix a bug: portuguese time formatting (#405)
|
||||
- Fix a bug: admin users groups being overriden by SSO group_id (#404)
|
||||
- Fix a bug: no statistics on trainings and spaces reservations
|
||||
- Fix a security issue: updated nokogiri to 1.13.9 to fix [GHSA-2qc6-mcvw-92cw](https://github.com/advisories/GHSA-2qc6-mcvw-92cw)
|
||||
|
||||
## v5.4.25 2022 October 19
|
||||
|
@ -7,39 +7,30 @@ class Statistics::Builders::ReservationsBuilderService
|
||||
class << self
|
||||
def build(options = default_options)
|
||||
# machine/space/training list
|
||||
%w[machine space training].each do |category|
|
||||
%w[machine space training event].each do |category|
|
||||
Statistics::FetcherService.send("reservations_#{category}_list", options).each do |r|
|
||||
%w[booking hour].each do |type|
|
||||
stat = Stats::Machine.new({ date: format_date(r[:date]),
|
||||
type: type,
|
||||
subType: r["#{category}_type".to_sym],
|
||||
ca: r[:ca],
|
||||
machineId: r["#{category}_id".to_sym],
|
||||
name: r["#{category}_name".to_sym],
|
||||
reservationId: r[:reservation_id] }.merge(user_info_stat(r)))
|
||||
stat.stat = (type == 'booking' ? 1 : r[:nb_hours])
|
||||
stat = "Stats::#{category.capitalize}"
|
||||
.constantize
|
||||
.new({ date: format_date(r[:date]),
|
||||
type: type,
|
||||
subType: r["#{category}_type".to_sym],
|
||||
ca: r[:ca],
|
||||
name: r["#{category}_name".to_sym],
|
||||
reservationId: r[:reservation_id] }.merge(user_info_stat(r)))
|
||||
stat[:stat] = (type == 'booking' ? 1 : r[:nb_hours])
|
||||
stat["#{category}Id".to_sym] = r["#{category}_id".to_sym]
|
||||
|
||||
if category == 'event'
|
||||
stat[:eventDate] = r[:event_date]
|
||||
stat[:eventTheme] = r[:event_theme]
|
||||
stat[:ageRange] = r[:age_range]
|
||||
end
|
||||
|
||||
stat.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# event list
|
||||
Statistics::FetcherService.reservations_event_list(options).each do |r|
|
||||
%w[booking hour].each do |type|
|
||||
stat = Stats::Event.new({ date: format_date(r[:date]),
|
||||
type: type,
|
||||
subType: r[:event_type],
|
||||
ca: r[:ca],
|
||||
eventId: r[:event_id],
|
||||
name: r[:event_name],
|
||||
eventDate: r[:event_date],
|
||||
reservationId: r[:reservation_id],
|
||||
eventTheme: r[:event_theme],
|
||||
ageRange: r[:age_range] }.merge(user_info_stat(r)))
|
||||
stat.stat = (type == 'booking' ? r[:nb_places] : r[:nb_hours])
|
||||
stat.save
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -50,6 +50,26 @@ class StatisticServiceTest < ActionDispatch::IntegrationTest
|
||||
}
|
||||
]
|
||||
}.to_json, headers: default_headers
|
||||
|
||||
# Create a training reservation (1 day ago)
|
||||
training = Training.find(1)
|
||||
tr_slot = Availability.find(2).slots.first
|
||||
post '/api/local_payment/confirm_payment', params: {
|
||||
customer_id: @user.id,
|
||||
items: [
|
||||
{
|
||||
reservation: {
|
||||
reservable_id: training.id,
|
||||
reservable_type: training.class.name,
|
||||
slots_reservations_attributes: [
|
||||
{
|
||||
slot_id: tr_slot.id
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}.to_json, headers: default_headers
|
||||
travel_back
|
||||
|
||||
# Crate another machine reservation (today)
|
||||
@ -105,6 +125,13 @@ class StatisticServiceTest < ActionDispatch::IntegrationTest
|
||||
assert_equal machine.friendly_id, stat_hour['subType']
|
||||
check_statistics_on_user(stat_hour)
|
||||
|
||||
# training
|
||||
stat_training = Stats::Training.search(query: { bool: { must: [{ term: { date: 1.day.ago.to_date.iso8601 } },
|
||||
{ term: { type: 'booking' } }] } }).first
|
||||
assert_not_nil stat_training
|
||||
assert_equal training.friendly_id, stat_training['subType']
|
||||
check_statistics_on_user(stat_training)
|
||||
|
||||
# subscription
|
||||
Stats::Subscription.refresh_index!
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user