49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
class DesktopOrbitController< ApplicationController
|
|
|
|
def orbit
|
|
render "desktop/orbit", :layout => false
|
|
end
|
|
|
|
def getevents
|
|
@event = params["event"]
|
|
@data = Array.new
|
|
@fromdate = params["from"]
|
|
case @event
|
|
when "papers"
|
|
@data = current_user.papers.where(:created_at.gt => Date.new(Integer(@fromdate[0]),Integer(@fromdate[1])-1),:created_at.lt => Date.new(Integer(@fromdate[0]),Integer(@fromdate[1])+1)).desc(:created_at)
|
|
end
|
|
render :json=>@data.to_json
|
|
end
|
|
|
|
def eventajaxload
|
|
@fromdate = params["from"]
|
|
@fromdate[0] = Integer(@fromdate[0])
|
|
@fromdate[1] = Integer(@fromdate[1])
|
|
@totalpapers = 0
|
|
@lastpaper = current_user.papers.all.desc(:created_at).last
|
|
@data = Array.new
|
|
while @totalpapers < 15
|
|
if @lastpaper.created_at > Date.new(@fromdate[0],@fromdate[1])
|
|
break
|
|
end
|
|
if(@fromdate[1] == 12)
|
|
@papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0]+1,1)).desc(:created_at)
|
|
else
|
|
@papers = current_user.papers.where(:created_at.gt => Date.new(@fromdate[0],@fromdate[1]),:created_at.lt => Date.new(@fromdate[0],@fromdate[1]+1)).desc(:created_at)
|
|
end
|
|
if(@papers.length > 0)
|
|
@data << {"papers" => @papers}
|
|
end
|
|
@totalpapers = @totalpapers + @papers.length
|
|
|
|
@fromdate[1] = @fromdate[1]-1
|
|
if(@fromdate[1] == 0)
|
|
@fromdate[1] = 12
|
|
@fromdate[0] = @fromdate[0] - 1
|
|
end
|
|
|
|
end
|
|
render :json=>@data.to_json
|
|
end
|
|
|
|
end |