module SnowmanIO::API::Extra::Meteor
Simple and a little bit ugly web sockets replacement
Public Class Methods
all(last)
click to toggle source
# File lib/snowman-io/api/extra/meteor.rb, line 6 def self.all(last) at = Time.at(last) now = Time.now if last == 0 { users: User.all, apps: App.all, metrics: Metric.all, checks: Check.all, users_deleted: [], apps_deleted: [], metrics_deleted: [], checks_deleted: [], last: now.to_i, version: (ENV["DEV_MODE"].to_i == 1 ? "__VERSION__" : SnowmanIO::VERSION) } else scope = Deleted.where(:created_at.gte => at) { users: User.where(:updated_at.gte => at), apps: App.where(:updated_at.gte => at), metrics: Metric.where(:updated_at.gte => at), checks: Check.where(:updated_at.gte => at), users_deleted: scope.where(model_kind: User.to_s).map(&:model_id), apps_deleted: scope.where(model_kind: App.to_s).map(&:model_id), metrics_deleted: scope.where(model_kind: Metric.to_s).map(&:model_id), checks_deleted: scope.where(model_kind: Check.to_s).map(&:model_id), last: now.to_i, version: (ENV["DEV_MODE"].to_i == 1 ? "__VERSION__" : SnowmanIO::VERSION) } end end
model_destroy(record)
click to toggle source
# File lib/snowman-io/api/extra/meteor.rb, line 40 def self.model_destroy(record) Deleted.create!(model_kind: record.class.to_s, model_id: record.id.to_s) record.destroy end