updates from Production version
This commit is contained in:
parent
f7b4a3fcce
commit
c240b89ed0
3
Gemfile
3
Gemfile
@ -31,7 +31,8 @@ gem 'newrelic_rpm'
|
||||
gem 'actionpack-xml_parser'
|
||||
gem 'activeadmin', github: 'gregbell/active_admin'
|
||||
gem 'chronic'
|
||||
gem "non-stupid-digest-assets"
|
||||
gem 'non-stupid-digest-assets'
|
||||
gem 'em-http-request'
|
||||
|
||||
# to use debugger
|
||||
# gem 'ruby-debug'
|
||||
|
@ -355,6 +355,7 @@ DEPENDENCIES
|
||||
database_cleaner (~> 1.2.0)
|
||||
devise
|
||||
dynamic_form
|
||||
em-http-request
|
||||
exception_notification
|
||||
factory_girl_rails
|
||||
faker
|
||||
|
@ -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
|
||||
|
@ -46,6 +46,7 @@
|
||||
# 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>
|
||||
|
@ -80,12 +80,14 @@ Thingspeak::Application.routes.draw do
|
||||
collection do
|
||||
get :public
|
||||
get :watched
|
||||
get :realtime
|
||||
end
|
||||
member do
|
||||
get :import
|
||||
post :upload
|
||||
post :clear
|
||||
put :watch
|
||||
post :realtime_update
|
||||
end
|
||||
resources :feed
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
class AddRealtimeIoSerialNumberToChannels < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :channels, :realtime_io_serial_number, :string, :limit => 36
|
||||
add_index :channels, :realtime_io_serial_number
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140410174033) do
|
||||
ActiveRecord::Schema.define(version: 20140515161337) do
|
||||
|
||||
create_table "active_admin_comments", force: true do |t|
|
||||
t.string "namespace"
|
||||
@ -103,10 +103,12 @@ ActiveRecord::Schema.define(version: 20140410174033) do
|
||||
t.boolean "clearing", default: false, null: false
|
||||
t.integer "ranking"
|
||||
t.string "user_agent"
|
||||
t.string "realtime_io_serial_number", limit: 36
|
||||
end
|
||||
|
||||
add_index "channels", ["public_flag", "last_entry_id", "updated_at"], name: "channels_public_viewable", using: :btree
|
||||
add_index "channels", ["ranking"], name: "index_channels_on_ranking", using: :btree
|
||||
add_index "channels", ["realtime_io_serial_number"], name: "index_channels_on_realtime_io_serial_number", using: :btree
|
||||
add_index "channels", ["slug"], name: "index_channels_on_slug", using: :btree
|
||||
add_index "channels", ["user_id"], name: "index_channels_on_user_id", using: :btree
|
||||
|
||||
|
@ -47,6 +47,7 @@
|
||||
# clearing :boolean default(FALSE), not null
|
||||
# ranking :integer
|
||||
# user_agent :string(255)
|
||||
# realtime_io_serial_number :string(36)
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
Loading…
Reference in New Issue
Block a user