Merge branch 'master' of github.com:iobridge/thingspeak

This commit is contained in:
Lee Lawlor 2015-03-19 11:33:25 -04:00
commit a1299229de
4 changed files with 34 additions and 44 deletions

View File

@ -154,7 +154,13 @@ class ChannelsController < ApplicationController
end end
def show def show
@channel = Channel.find(params[:id]) if params[:id] @channel = Channel.find_by_id(params[:id])
# show the public show page if no channel found
if @channel.blank?
@channel = Channel.new(public_flag: false, name: "Channel #{params[:id]}", id: params[:id])
render "public_show" and return
end
@title = @channel.name @title = @channel.name
@domain = domain @domain = domain
@ -369,6 +375,12 @@ class ChannelsController < ApplicationController
if channel.save && feed.save if channel.save && feed.save
status = entry_id status = entry_id
# queue reacts, but don't cause an error
begin
channel.queue_react
rescue
end
# check for tweet # check for tweet
if params[:twitter] && params[:tweet] if params[:twitter] && params[:tweet]
# check username # check username

View File

@ -26,9 +26,6 @@ class Feed < ActiveRecord::Base
extend FeedHelper extend FeedHelper
belongs_to :channel belongs_to :channel
after_commit :queue_react
delegate :queue_react, :to => :channel
self.include_root_in_json = false self.include_root_in_json = false
attr_readonly :created_at attr_readonly :created_at
@ -156,4 +153,3 @@ class Feed < ActiveRecord::Base
end end
end end

View File

@ -2,6 +2,7 @@
<ol class="breadcrumb"> <ol class="breadcrumb">
<%# g1199258 %> <%# g1199258 %>
<li><%= link_to t(:channels), auth_channels_path %></li> <li><%= link_to t(:channels), auth_channels_path %></li>
<li class="active"><%= @channel.name %></li> <li class="active"><%= @channel.public? ? @channel.name : "Channel #{@channel.id}" %></li>
</ol> </ol>
</div> </div>

View File

@ -16,8 +16,8 @@ ActiveRecord::Schema.define(version: 20150311201046) do
create_table "active_admin_comments", force: true do |t| create_table "active_admin_comments", force: true do |t|
t.string "namespace" t.string "namespace"
t.text "body" t.text "body"
t.string "resource_id", null: false t.string "resource_id", limit: 50, null: false
t.string "resource_type", null: false t.string "resource_type", limit: 50, null: false
t.integer "author_id" t.integer "author_id"
t.string "author_type" t.string "author_type"
t.datetime "created_at" t.datetime "created_at"
@ -167,15 +167,6 @@ ActiveRecord::Schema.define(version: 20150311201046) do
add_index "devices", ["mac_address"], name: "index_devices_on_mac_address", using: :btree add_index "devices", ["mac_address"], name: "index_devices_on_mac_address", using: :btree
add_index "devices", ["user_id"], name: "index_devices_on_user_id", using: :btree add_index "devices", ["user_id"], name: "index_devices_on_user_id", using: :btree
create_table "events", force: true do |t|
t.integer "timecontrol_id"
t.datetime "run_at"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "events", ["run_at"], name: "index_events_on_run_at", using: :btree
create_table "failedlogins", force: true do |t| create_table "failedlogins", force: true do |t|
t.string "login" t.string "login"
t.string "password" t.string "password"
@ -272,6 +263,23 @@ ActiveRecord::Schema.define(version: 20150311201046) do
add_index "reacts", ["run_interval"], name: "index_reacts_on_run_interval", using: :btree add_index "reacts", ["run_interval"], name: "index_reacts_on_run_interval", using: :btree
add_index "reacts", ["user_id"], name: "index_reacts_on_user_id", using: :btree add_index "reacts", ["user_id"], name: "index_reacts_on_user_id", using: :btree
create_table "scheduled_thinghttps", force: true do |t|
t.integer "user_id"
t.string "name"
t.boolean "activated", default: true, null: false
t.integer "run_interval"
t.integer "thinghttp_id"
t.integer "channel_id"
t.string "field_name"
t.datetime "last_run_at"
t.string "last_result"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "scheduled_thinghttps", ["activated", "run_interval"], name: "index_scheduled_thinghttps_on_activated_and_run_interval", using: :btree
add_index "scheduled_thinghttps", ["user_id"], name: "index_scheduled_thinghttps_on_user_id", using: :btree
create_table "taggings", force: true do |t| create_table "taggings", force: true do |t|
t.integer "tag_id" t.integer "tag_id"
t.integer "channel_id" t.integer "channel_id"
@ -322,32 +330,6 @@ ActiveRecord::Schema.define(version: 20150311201046) do
add_index "thinghttps", ["api_key"], name: "index_thinghttps_on_api_key", using: :btree add_index "thinghttps", ["api_key"], name: "index_thinghttps_on_api_key", using: :btree
add_index "thinghttps", ["user_id"], name: "index_thinghttps_on_user_id", using: :btree add_index "thinghttps", ["user_id"], name: "index_thinghttps_on_user_id", using: :btree
create_table "timecontrols", force: true do |t|
t.integer "user_id"
t.integer "schedulable_id"
t.string "schedulable_type", limit: 50
t.string "frequency", limit: 20
t.integer "day", limit: 1
t.integer "hour", limit: 1
t.integer "minute", limit: 1
t.integer "parent_id"
t.datetime "last_event_at"
t.text "last_response"
t.datetime "created_at"
t.datetime "updated_at"
t.string "name"
t.datetime "run_at"
t.integer "fuzzy_seconds", default: 0
t.string "schedulable_value"
t.integer "schedulable_position"
end
add_index "timecontrols", ["frequency", "minute", "hour", "day"], name: "index_timecontrols_on_frequency_and_minute_and_hour_and_day", using: :btree
add_index "timecontrols", ["parent_id"], name: "index_timecontrols_on_parent_id", using: :btree
add_index "timecontrols", ["run_at"], name: "index_timecontrols_on_run_at", using: :btree
add_index "timecontrols", ["schedulable_id", "schedulable_type"], name: "index_timecontrols_on_schedulable_id_and_schedulable_type", using: :btree
add_index "timecontrols", ["user_id"], name: "index_timecontrols_on_user_id", using: :btree
create_table "tweetcontrols", force: true do |t| create_table "tweetcontrols", force: true do |t|
t.string "screen_name" t.string "screen_name"
t.string "trigger" t.string "trigger"
@ -398,7 +380,6 @@ ActiveRecord::Schema.define(version: 20150311201046) do
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false t.integer "sign_in_count", default: 0, null: false
t.string "authentication_token" t.string "authentication_token"
t.datetime "terms_agreed_at"
end end
add_index "users", ["api_key"], name: "index_users_on_api_key", using: :btree add_index "users", ["api_key"], name: "index_users_on_api_key", using: :btree