Sha256: d1767ca27bde1fec6670e39ed8ee348caa8830adf9016d99205c5421933e6e36

Contents?: true

Size: 868 Bytes

Versions: 1

Compression:

Stored size: 868 Bytes

Contents

module Logman
  class LogAPI < ConsoleBase
    
    get '/api/buckets/:id/logs',:auth=>:user do
      bucket = Bucket.find(params[:id])
      
      if bucket.nil?
        status 404
      else
        page = params[:page] || 1
         
        pagination={
          :order    => :created_at.desc,
          :per_page => params[:per_page] || 10, 
          :page     => page
        }
        
       
        data = bucket.logs.paginate(pagination)
        
        res ={
          :page => page,
          :items => data,
          :total_items => bucket.logs.count,
        }
        
        json res
        
      end
    end
    
    get '/app/dashboard-view',:auth=>:user do
      graph_data = (7.days.ago.to_date..Date.today).map {|t| {date: t, count: Log.count_on_date(t)} }
      erb :dashboard, :locals=>{:graph_data=> graph_data}
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logman-0.0.2 lib/console/log_api.rb