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
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
14
db/schema.rb
14
db/schema.rb
@ -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"
|
||||
@ -63,8 +63,8 @@ ActiveRecord::Schema.define(version: 20140410174033) do
|
||||
t.integer "user_id"
|
||||
t.string "name"
|
||||
t.string "description"
|
||||
t.decimal "latitude", precision: 15, scale: 10
|
||||
t.decimal "longitude", precision: 15, scale: 10
|
||||
t.decimal "latitude", precision: 15, scale: 10
|
||||
t.decimal "longitude", precision: 15, scale: 10
|
||||
t.string "field1"
|
||||
t.string "field2"
|
||||
t.string "field3"
|
||||
@ -85,7 +85,7 @@ ActiveRecord::Schema.define(version: 20140410174033) do
|
||||
t.datetime "updated_at"
|
||||
t.string "elevation"
|
||||
t.integer "last_entry_id"
|
||||
t.boolean "public_flag", default: false
|
||||
t.boolean "public_flag", default: false
|
||||
t.string "options1"
|
||||
t.string "options2"
|
||||
t.string "options3"
|
||||
@ -94,19 +94,21 @@ ActiveRecord::Schema.define(version: 20140410174033) do
|
||||
t.string "options6"
|
||||
t.string "options7"
|
||||
t.string "options8"
|
||||
t.boolean "social", default: false
|
||||
t.boolean "social", default: false
|
||||
t.string "slug"
|
||||
t.string "status"
|
||||
t.string "url"
|
||||
t.string "video_id"
|
||||
t.string "video_type"
|
||||
t.boolean "clearing", default: false, null: false
|
||||
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
|
||||
|
||||
|
@ -3,50 +3,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)
|
||||
#
|
||||
|
||||
require 'spec_helper'
|
||||
|
Loading…
Reference in New Issue
Block a user