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
6f087c6a
Commit
6f087c6a
authored
Sep 26, 2019
by
alain
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix nextlink filter / redis cache key to include date start/end
parent
74d9e8a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
backend/server.rb
backend/server.rb
+5
-4
No files found.
backend/server.rb
View file @
6f087c6a
...
...
@@ -108,10 +108,11 @@ def retrieveSensorData(params)
date_end
=
params
[
:end
]
uri
=
"
#{
$base_url
}
/Things?$filter=name%20eq%20%27HLL_hl_device_
#{
id
}
%27&$expand=Datastreams($filter=contains(name,%27
#{
type
}
%27))"
cache_key
=
"
#{
uri
}
_
#{
date_start
}
_
#{
date_end
}
"
body
=
nil
if
(
$redis
.
exists
uri
)
body
=
$redis
.
get
uri
if
(
$redis
.
exists
cache_key
)
body
=
$redis
.
get
cache_key
puts
"cache hit"
else
...
...
@@ -136,7 +137,7 @@ def retrieveSensorData(params)
{
ds_names
[
index
]
=>
all_values
.
flatten
}
}
body
=
all_pages
.
to_json
$redis
.
set
uri
,
body
,
{
:ex
=>
3600
}
$redis
.
set
cache_key
,
body
,
{
:ex
=>
3600
}
end
body
end
...
...
@@ -147,7 +148,7 @@ def getPageRecursive(pages,uri,filter)
response
=
RestClient
.
get
uri
page
=
JSON
.
parse
(
response
)
nextLink
=
page
[
"@iot.nextLink"
]
nextLink
=
nextLink
+
"
&$select=phenomenonTime,result"
if
(
filter
)
nextLink
=
"
#{
nextLink
}
&$select=phenomenonTime,result"
if
(
filter
and
nextLink
!=
nil
and
not
nextLink
.
empty?
)
pages
<<
page
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