1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-02-26 20:54:21 +01:00

[export] handle data type in custom fields

This commit is contained in:
Sylvain 2016-07-07 16:34:28 +02:00
parent 022db4e486
commit 0f7f2c256a

View File

@ -46,9 +46,26 @@ wb.add_worksheet(name: @index.label) do |sheet|
types.push :string
end
@fields.each do |f|
data.push hit['_source'][f.key]
styles.push nil
types.push :string
field_data = hit['_source'][f.key]
case f.data_type
when 'date'
data.push Date::strptime(field_data,'%Y-%m-%d')
styles.push date
types.push :date
when 'list'
data.push field_data.map{|e| e['name'] }.join(', ')
styles.push nil
types.push :string
when 'number'
data.push field_data
styles.push nil
types.push :float
else
data.push field_data
styles.push nil
types.push :string
end
end
if @index.ca
data.push hit['_source']['ca']