mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-29 18:52:22 +01:00
add age&theme filters to statistics
This commit is contained in:
parent
5a0bb86394
commit
e930e04ed6
@ -6,5 +6,7 @@ module Stats
|
||||
|
||||
attribute :eventId, Integer
|
||||
attribute :eventDate, String
|
||||
attribute :ageRange, String
|
||||
attribute :eventTheme, String
|
||||
end
|
||||
end
|
||||
|
@ -68,7 +68,9 @@ class StatisticService
|
||||
eventId: r.event_id,
|
||||
name: r.event_name,
|
||||
eventDate: r.event_date,
|
||||
reservationId: r.reservation_id
|
||||
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
|
||||
@ -201,6 +203,8 @@ class StatisticService
|
||||
event_type: r.reservable.categories.first.name,
|
||||
event_name: r.reservable.name,
|
||||
event_date: slot.start_at.to_date,
|
||||
event_theme: (r.reservable.event_themes.first ? r.reservable.event_themes.first.name : ''),
|
||||
age_range: (r.reservable.age_range_id ? r.reservable.age_range.name : ''),
|
||||
nb_places: r.nb_reserve_places + r.nb_reserve_reduced_places,
|
||||
nb_hours: difference_in_hours(slot.start_at, slot.end_at),
|
||||
ca: calcul_ca(r.invoice)
|
||||
|
@ -244,6 +244,8 @@ en:
|
||||
event_id: "Event ID"
|
||||
event_date: "Event Date"
|
||||
event_name: "Event Name"
|
||||
event_theme: "Theme"
|
||||
age_range: "Age Range"
|
||||
themes: "Themes"
|
||||
components: "Components"
|
||||
machines: "Machines"
|
||||
|
@ -244,6 +244,8 @@ fr:
|
||||
event_id: "ID Évènement"
|
||||
event_date: "Date Évènement"
|
||||
event_name: "Nom Évènement"
|
||||
event_theme: "Thématique"
|
||||
age_range: "Tranche d'âge"
|
||||
themes: "Thèmes"
|
||||
components: "Composants"
|
||||
machines: "Machines"
|
||||
|
@ -0,0 +1,6 @@
|
||||
class AddEventThemeAndAgeRangeToStatisticField < ActiveRecord::Migration
|
||||
def change
|
||||
StatisticField.create!({key:'eventTheme', label:I18n.t('statistics.event_theme'), statistic_index_id: 4, data_type: 'text'})
|
||||
StatisticField.create!({key:'ageRange', label:I18n.t('statistics.age_range'), statistic_index_id: 4, data_type: 'text'})
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160630083759) do
|
||||
ActiveRecord::Schema.define(version: 20160630100137) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -27,7 +27,9 @@ if StatisticField.count == 0
|
||||
{key:'components', label:I18n.t('statistics.components'), statistic_index_id: 6, data_type: 'list'},
|
||||
{key:'machines', label:I18n.t('statistics.machines'), statistic_index_id: 6, data_type: 'list'},
|
||||
{key:'name', label:I18n.t('statistics.event_name'), statistic_index_id: 4, data_type: 'text'},
|
||||
{key:'userId', label:I18n.t('statistics.user_id'), statistic_index_id: 7, data_type: 'index'}
|
||||
{key:'userId', label:I18n.t('statistics.user_id'), statistic_index_id: 7, data_type: 'index'},
|
||||
{key:'eventTheme', label:I18n.t('statistics.event_theme'), statistic_index_id: 4, data_type: 'text'},
|
||||
{key:'ageRange', label:I18n.t('statistics.age_range'), statistic_index_id: 4, data_type: 'text'}
|
||||
])
|
||||
end
|
||||
|
||||
|
@ -408,6 +408,14 @@ http://localhost:9200/stats/_mapping?pretty
|
||||
},
|
||||
"userId" : {
|
||||
"type" : "long"
|
||||
},
|
||||
"ageRange" : {
|
||||
"type" : "string",
|
||||
"index" : "not_analyzed"
|
||||
},
|
||||
"eventTheme" : {
|
||||
"type" : "string",
|
||||
"index" : "not_analyzed"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
20
test/fixtures/statistic_fields.yml
vendored
20
test/fixtures/statistic_fields.yml
vendored
@ -88,3 +88,23 @@ statistic_field_10:
|
||||
created_at: 2016-04-04 14:11:33.423307000 Z
|
||||
updated_at: 2016-04-04 14:11:33.423307000 Z
|
||||
data_type: text
|
||||
|
||||
statistic_field_11:
|
||||
id: 11
|
||||
statistic_index_id: 4
|
||||
key: ageRange
|
||||
label: Tranche d'âge
|
||||
created_at: 2016-06-30 12:10:49.812226000 Z
|
||||
updated_at: 2016-06-30 12:10:49.812226000 Z
|
||||
data_type: text
|
||||
|
||||
|
||||
statistic_field_12:
|
||||
id: 12
|
||||
statistic_index_id: 4
|
||||
key: eventTheme
|
||||
label: Thématique
|
||||
created_at: 2016-06-30 12:10:49.814331000 Z
|
||||
updated_at: 2016-06-30 12:10:49.814331000 Z
|
||||
data_type: text
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user