Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
lumen-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1ef89956
authored
Jun 02, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
fixed legacy parser for discrete streams
parent
9fa9dffb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
18 deletions
app/adapters/db_adapter.rb
spec/controllers/db_elements_controller_spec.rb
app/adapters/db_adapter.rb
View file @
1ef89956
...
@@ -55,18 +55,6 @@ class DbAdapter
...
@@ -55,18 +55,6 @@ class DbAdapter
# The streams are not pure attributes, pull them out
# The streams are not pure attributes, pull them out
elements
=
metadata
.
delete
(
:streams
)
||
[]
elements
=
metadata
.
delete
(
:streams
)
||
[]
elements
.
each
(
&
:symbolize_keys!
)
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:
# Create the schema:
# 3 elements: path, attributes, elements
# 3 elements: path, attributes, elements
{
{
...
@@ -197,8 +185,18 @@ class DbAdapter
...
@@ -197,8 +185,18 @@ class DbAdapter
# sanitize 'streams' (elements) parameters
# sanitize 'streams' (elements) parameters
element_attrs
=
DbElement
.
attribute_names
.
map
(
&
:to_sym
)
element_attrs
=
DbElement
.
attribute_names
.
map
(
&
:to_sym
)
metadata
[
'streams'
].
map!
do
|
element
|
metadata
[
'streams'
].
map!
do
|
element
|
element
.
symbolize_keys
# map the legacy discrete flag to new type setting
.
slice
(
*
element_attrs
)
# 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
end
end
metadata
.
symbolize_keys
metadata
.
symbolize_keys
...
...
spec/controllers/db_elements_controller_spec.rb
View file @
1ef89956
...
@@ -17,7 +17,7 @@ RSpec.describe DbElementsController, type: :request do
...
@@ -17,7 +17,7 @@ RSpec.describe DbElementsController, type: :request do
stream
.
db_elements
<<
@elem1
stream
.
db_elements
<<
@elem1
stream
.
db_elements
<<
@elem2
stream
.
db_elements
<<
@elem2
end
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'
},
@service_data
=
[{
id:
@elem1
.
id
,
data:
'mock1'
},
...
@@ -33,14 +33,12 @@ RSpec.describe DbElementsController, type: :request do
...
@@ -33,14 +33,12 @@ RSpec.describe DbElementsController, type: :request do
@auth_headers
=
user1
.
create_new_auth_token
@auth_headers
=
user1
.
create_new_auth_token
get
'/db_elements/data.json'
,
get
'/db_elements/data.json'
,
params:
{
elements:
[
@elem1
.
id
,
@elem2
.
id
].
to_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
headers:
@auth_headers
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
).
to
have_http_status
(
:ok
)
# check to make sure JSON renders the elements
# check to make sure JSON renders the elements
body
=
JSON
.
parse
(
response
.
body
)
body
=
JSON
.
parse
(
response
.
body
)
expect
(
body
[
'data'
].
count
).
to
eq
(
2
)
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
end
it
'returns error if time bounds are invalid'
do
it
'returns error if time bounds are invalid'
do
@auth_headers
=
user1
.
create_new_auth_token
@auth_headers
=
user1
.
create_new_auth_token
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment