updates from Production version
This commit is contained in:
@ -1,11 +1,19 @@
|
||||
class ChannelsController < ApplicationController
|
||||
include ChannelsHelper, ApiKeys
|
||||
before_filter :require_user, :except => [ :show, :post_data, :social_show, :social_feed, :public]
|
||||
before_filter :require_user, :except => [:realtime, :realtime_update, :show, :post_data, :social_show, :social_feed, :public]
|
||||
before_filter :set_channels_menu
|
||||
layout 'application', :except => [:social_show, :social_feed]
|
||||
protect_from_forgery :except => [:post_data, :create, :destroy, :clear]
|
||||
protect_from_forgery :except => [:realtime, :realtime_update, :post_data, :create, :destroy, :clear]
|
||||
require 'csv'
|
||||
|
||||
# get list of all realtime channels
|
||||
def realtime
|
||||
# error if no key
|
||||
respond_with_error(:error_auth_required) and return if params[:realtime_key] != REALTIME_DAEMON_KEY
|
||||
channels = Channel.where("realtime_io_serial_number IS NOT NULL")
|
||||
render :json => channels.to_json(:root => false, :only => [:id, :realtime_io_serial_number])
|
||||
end
|
||||
|
||||
# view list of watched channels
|
||||
def watched
|
||||
@channels = current_user.watched_channels
|
||||
@ -235,6 +243,33 @@ class ChannelsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# post from realtime.io daemon
|
||||
def realtime_update
|
||||
# exit if not authenticated
|
||||
respond_with_error(:error_auth_required) and return if params[:realtime_key] != REALTIME_DAEMON_KEY
|
||||
|
||||
# set feed and channel
|
||||
feed = Feed.new
|
||||
channel = Channel.find(params[:id])
|
||||
|
||||
# update entry_id for channel and feed
|
||||
entry_id = channel.next_entry_id
|
||||
channel.last_entry_id = entry_id
|
||||
feed.entry_id = entry_id
|
||||
# set user agent
|
||||
channel.user_agent = 'realtime.io'
|
||||
|
||||
# set feed details
|
||||
feed.channel_id = channel.id
|
||||
feed.status = params[:status]
|
||||
|
||||
# save channel and feed
|
||||
channel.save
|
||||
feed.save
|
||||
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
# response is '0' if failure, 'entry_id' if success
|
||||
def post_data
|
||||
|
||||
|
@ -54,11 +54,11 @@ class StreamController < ApplicationController
|
||||
|
||||
def stream_example
|
||||
# get the channel
|
||||
channel = Channel.find(params[:channel_id])
|
||||
#channel = Channel.find(params[:channel_id])
|
||||
|
||||
# stream the response
|
||||
response.headers['Content-Type'] = 'text/csv'
|
||||
response.headers['Content-Disposition'] = 'attachment; filename=feeds.csv'
|
||||
#response.headers['Content-Type'] = 'text/csv'
|
||||
#response.headers['Content-Disposition'] = 'attachment; filename=feeds.csv'
|
||||
20.times {
|
||||
response.stream.write "hello world\n"
|
||||
sleep 1
|
||||
|
@ -2,50 +2,51 @@
|
||||
#
|
||||
# Table name: channels
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer
|
||||
# name :string(255)
|
||||
# description :string(255)
|
||||
# latitude :decimal(15, 10)
|
||||
# longitude :decimal(15, 10)
|
||||
# field1 :string(255)
|
||||
# field2 :string(255)
|
||||
# field3 :string(255)
|
||||
# field4 :string(255)
|
||||
# field5 :string(255)
|
||||
# field6 :string(255)
|
||||
# field7 :string(255)
|
||||
# field8 :string(255)
|
||||
# scale1 :integer
|
||||
# scale2 :integer
|
||||
# scale3 :integer
|
||||
# scale4 :integer
|
||||
# scale5 :integer
|
||||
# scale6 :integer
|
||||
# scale7 :integer
|
||||
# scale8 :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# elevation :string(255)
|
||||
# last_entry_id :integer
|
||||
# public_flag :boolean default(FALSE)
|
||||
# options1 :string(255)
|
||||
# options2 :string(255)
|
||||
# options3 :string(255)
|
||||
# options4 :string(255)
|
||||
# options5 :string(255)
|
||||
# options6 :string(255)
|
||||
# options7 :string(255)
|
||||
# options8 :string(255)
|
||||
# social :boolean default(FALSE)
|
||||
# slug :string(255)
|
||||
# status :string(255)
|
||||
# url :string(255)
|
||||
# video_id :string(255)
|
||||
# video_type :string(255)
|
||||
# clearing :boolean default(FALSE), not null
|
||||
# ranking :integer
|
||||
# user_agent :string(255)
|
||||
# id :integer not null, primary key
|
||||
# user_id :integer
|
||||
# name :string(255)
|
||||
# description :string(255)
|
||||
# latitude :decimal(15, 10)
|
||||
# longitude :decimal(15, 10)
|
||||
# field1 :string(255)
|
||||
# field2 :string(255)
|
||||
# field3 :string(255)
|
||||
# field4 :string(255)
|
||||
# field5 :string(255)
|
||||
# field6 :string(255)
|
||||
# field7 :string(255)
|
||||
# field8 :string(255)
|
||||
# scale1 :integer
|
||||
# scale2 :integer
|
||||
# scale3 :integer
|
||||
# scale4 :integer
|
||||
# scale5 :integer
|
||||
# scale6 :integer
|
||||
# scale7 :integer
|
||||
# scale8 :integer
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# elevation :string(255)
|
||||
# last_entry_id :integer
|
||||
# public_flag :boolean default(FALSE)
|
||||
# options1 :string(255)
|
||||
# options2 :string(255)
|
||||
# options3 :string(255)
|
||||
# options4 :string(255)
|
||||
# options5 :string(255)
|
||||
# options6 :string(255)
|
||||
# options7 :string(255)
|
||||
# options8 :string(255)
|
||||
# social :boolean default(FALSE)
|
||||
# slug :string(255)
|
||||
# status :string(255)
|
||||
# url :string(255)
|
||||
# video_id :string(255)
|
||||
# video_type :string(255)
|
||||
# clearing :boolean default(FALSE), not null
|
||||
# ranking :integer
|
||||
# user_agent :string(255)
|
||||
# realtime_io_serial_number :string(36)
|
||||
#
|
||||
|
||||
class Channel < ActiveRecord::Base
|
||||
|
@ -27,7 +27,7 @@
|
||||
<li><b>yaxis</b> (string) Chart's y-axis label, default: field name (optional)</li>
|
||||
<li><b>color</b> (string) Line color, default: red (optional)</li>
|
||||
<li><b>bgcolor</b> (string) Background color, default: white (optional)</li>
|
||||
<li><b>type</b> (line/bar/column) Type of chart, default: line (optional)</li>
|
||||
<li><b>type</b> (line/bar/column/spline) Type of chart, default: line (optional)</li>
|
||||
<li><b>width</b> (integer) Chart width in pixels, iframe width will be 20px larger, default chart width: 400. Set to <i>auto</i> to automatically adjust chart size based on its parent container. (optional)</li>
|
||||
<li><b>height</b> (integer) Chart height in pixels, iframe height will be 20px larger, default chart height: 200. Set to <i>auto</i> to automatically adjust chart size based on its parent container. (optional)</li>
|
||||
<li><b>dynamic</b> (true/false) Make chart update automatically every 15 seconds, default: false (optional)</li>
|
||||
|
Reference in New Issue
Block a user