Posts

Showing posts from October, 2015

Specific Field Update by Use Map Function

Rails Resque gem 'resque-status' bundle 1. ) app/workers/transcoder.rb class Transcoder include Resque::Plugins::Status @queue = :transcoder def perform puts "transcoder starting..." end end 2.) config/initializers/resque.rb require 'redis' require 'resque/status_server' $redis = Redis.new RS=Resque::Plugins::Status Resque::Plugins::Status::Hash.expire_in = (48 * 60 * 60) # 2 days in seconds 3.) lib/resque.rake require 'bundler/setup' Bundler.require(:default) # require 'nish-news' require 'resque/tasks' task "resque:setup" do ENV['QUEUE'] = '*' Resque.before_fork = Proc.new { ActiveRecord::Base.establish_connection } end 4. ) Procfile web: bundle exec rails s -p 3000 worker1: bundle exec rake environment resque:work QUEUE='transcoder' and foreman start https://gist.github.com/muratatak77/bbe743e379add276cf59cc

Moment JS - Some date functions

exports.getDateByRange = function(req, options) { var start_date = req.param('start_date'); var end_date = req.param('end_date'); var date_type = req.param('date_type') || "yesterday_revenue"; if (date_type == "yesterday_revenue") { options.start_date = moment().subtract(1, 'day').startOf('day')._d; options.end_date = moment().subtract(1, 'day').startOf('day').add({ hour: 23, minute: 59 })._d; } else if (date_type == "week_to_date_revenue") { options.start_date = moment().startOf('week')._d; options.end_date = moment()._d; } else if (date_type == "month_to_date_revenue") { options.start_date = moment().startOf('month')._d; options.end_date = moment()._d; } else if (date_type == "quarter_to_date_revenue") { options.start_date = moment().startOf('quarter')._d; options.end_date