Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ReportsController < ApplicationController
- def index
- now = Time.now
- @start = Date.strptime(params[:start], "%Y-%m-%d") if params[:start].present?
- @start ||= now.beginning_of_month.to_date
- @end = Date.strptime(params[:end], "%Y-%m-%d") if params[:end].present?
- @end ||= now.end_of_month.to_date
- @customers = Customer.select("COUNT(*) AS count_all, date(customers.created_at) AS date_created_at")
- .joins(:campaign => :user)
- .where("users.id" => current_user.id)
- .where("customers.created_at BETWEEN ? AND ?", @start, @end)
- .group("date(customers.created_at)")
- .order(:date_created_at)
- @visitors = Visitor.select("COUNT(*) AS count_all, date(created_at) AS date_created_at")
- .where("created_at BETWEEN ? AND ?", @start, @end)
- .group("date(created_at)")
- .order(:date_created_at)
- end
- end
Add Comment
Please, Sign In to add comment