Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
code
hollandse-luchten-data-app
Commits
3b3f30d6
Commit
3b3f30d6
authored
Sep 27, 2019
by
alain
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter out things without datastreams
parent
622c2f62
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
backend/README.md
backend/README.md
+6
-0
backend/server.rb
backend/server.rb
+4
-2
No files found.
backend/README.md
View file @
3b3f30d6
...
...
@@ -9,6 +9,12 @@
`gem install csv`
`gem install redis`
`gem install rack`
`gem install rack-cors`
## to start
`brew services start redis`
...
...
backend/server.rb
View file @
3b3f30d6
...
...
@@ -37,14 +37,14 @@ get '/sensor/:type' do
end
body
=
nil
if
(
$redis
.
exists
uri
)
if
(
$redis
.
exists
uri
)
body
=
$redis
.
get
uri
puts
"cache hit"
else
pages
=
[]
getPageRecursive
(
pages
,
uri
,
false
)
things
=
pages
.
map
{
|
page
|
page
[
"value"
]}.
flatten
things
=
pages
.
map
{
|
page
|
page
[
"value"
]}.
flatten
.
select
{
|
thing
|
thing
[
"Datastreams"
]
!=
nil
}
result
=
things
.
map
{
|
thing
|
ds_list
=
thing
[
"Datastreams"
]
...
...
@@ -145,10 +145,12 @@ end
def
getPageRecursive
(
pages
,
uri
,
filter
)
#start = Time.now
response
=
RestClient
.
get
uri
page
=
JSON
.
parse
(
response
)
nextLink
=
page
[
"@iot.nextLink"
]
nextLink
=
"
#{
nextLink
}
&$select=phenomenonTime,result"
if
(
filter
and
nextLink
!=
nil
and
not
nextLink
.
empty?
)
pages
<<
page
#puts "#{uri}: #{Time.now - start} s"
getPageRecursive
(
pages
,
nextLink
,
filter
)
if
(
nextLink
!=
nil
and
not
nextLink
.
empty?
)
end
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