Commit 1ef89956 by John Doe

fixed legacy parser for discrete streams

parent 9fa9dffb
......@@ -55,18 +55,6 @@ class DbAdapter
# The streams are not pure attributes, pull them out
elements = metadata.delete(:streams) || []
elements.each(&:symbolize_keys!)
# map the legacy discrete flag to new type setting
# discrete == True => type = event
# discrete == False => type = continuous
elements.map! do |e|
next unless e[:type].nil?
e[:display_type] = if e[:discrete]
'event'
else
'continuous'
end
e
end
# Create the schema:
# 3 elements: path, attributes, elements
{
......@@ -197,8 +185,18 @@ class DbAdapter
# sanitize 'streams' (elements) parameters
element_attrs = DbElement.attribute_names.map(&:to_sym)
metadata['streams'].map! do |element|
element.symbolize_keys
.slice(*element_attrs)
# map the legacy discrete flag to new type setting
# discrete == True => type = event
# discrete == False => type = continuous
element.symbolize_keys!
if element[:display_type].nil?
if element[:discrete]
element[:display_type] = 'event'
else
element[:display_type] = 'continuous'
end
end
element.slice(*element_attrs)
end
end
metadata.symbolize_keys
......
......@@ -17,7 +17,7 @@ RSpec.describe DbElementsController, type: :request do
stream.db_elements << @elem1
stream.db_elements << @elem2
end
it "returns elements with data and updates the user's home view" do
it "returns elements with data" do
@service_data = [{ id: @elem1.id, data: 'mock1' },
......@@ -33,14 +33,12 @@ RSpec.describe DbElementsController, type: :request do
@auth_headers = user1.create_new_auth_token
get '/db_elements/data.json',
params: { elements: [@elem1.id, @elem2.id].to_json,
start_time: 0, end_time: 100, redux_json: 'new home view' },
start_time: 0, end_time: 100 },
headers: @auth_headers
expect(response).to have_http_status(:ok)
# check to make sure JSON renders the elements
body = JSON.parse(response.body)
expect(body['data'].count).to eq(2)
# check the user home view
expect(user1.reload.home_data_view.redux_json).to eq('new home view')
end
it 'returns error if time bounds are invalid' do
@auth_headers = user1.create_new_auth_token
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment