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
b4364f2f
authored
May 20, 2017
by
John Doe
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
working on stream download
parent
7c967683
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
app/controllers/db_streams_controller.rb
app/views/db_streams/data.csv.erb
config/routes.rb
app/controllers/db_streams_controller.rb
View file @
b4364f2f
...
...
@@ -3,7 +3,8 @@
# Controller for DbStreams
class
DbStreamsController
<
ApplicationController
before_action
:authenticate_user!
before_action
:set_stream
,
only:
[
:update
]
before_action
:set_stream
,
only:
[
:update
,
:data
]
before_action
:authorize_viewer
,
only:
[
:data
]
before_action
:authorize_owner
,
only:
[
:update
]
def
update
...
...
@@ -13,6 +14,11 @@ class DbStreamsController < ApplicationController
render
status:
@service
.
success?
?
:
ok
:
:unprocessable_entity
end
def
data
headers
[
"Content-Disposition"
]
=
"attachment; filename='
#{
@db_stream
.
name
}
.txt'"
render
:layout
=>
false
,
:content_type
=>
"text/plain"
end
private
def
stream_params
...
...
app/views/db_streams/data.csv.erb
0 → 100644
View file @
b4364f2f
###############################################
# Stream:
<%=
@db_stream
.
name
%>
# Path:
<%=
@db_stream
.
path
%>
# Source:
<%=
@nilm
.
name
%>
<%
unless
@nilm
.
description
.
blank?
%>
(
<%=
@nilm
.
description
%>
)
<%
end
%>
#
#
# start: --
# end: --
# total time: --
# total rows: --
#
#The raw data file can be retrieved at the following URL:
#
<%=
@db
.
url
%>
/stream/extract?path=
<%=
@db_stream
.
path
%>
&
start=?
&
end=?
#
# to import in matlab run:
# nilm = importdata('thisfilename.txt')
#
# nilm.textdata: this help text
# nilm.data: the data
#
# The data has
<%=
@db_stream
.
db_elements
.
count
+
1
%>
columns with the following format:
#
# Column 1: Timestamp (microseconds)
<%
col
=
2
%>
<%
@db_stream
.
db_elements
.
each
do
|
element
|
%>
# Column
<%=
col
%>
:
<%=
element
.
name
%>
(
<%=
element
.
units
%>
)
<%
col
+=
1
%>
<%
end
%>
#
config/routes.rb
View file @
b4364f2f
...
...
@@ -8,7 +8,11 @@ Rails.application.routes.draw do
resources
:data_views
resources
:dbs
,
only:
[
:show
,
:update
]
resources
:db_folders
,
only:
[
:show
,
:update
]
resources
:db_streams
,
only:
[
:update
]
resources
:db_streams
,
only:
[
:update
]
do
member
do
post
'data'
end
end
resources
:db_elements
,
only:
[
:index
]
do
collection
do
get
'data'
...
...
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