Add home page

This commit is contained in:
Omar Roth 2018-02-05 17:56:40 -06:00
parent 3bd6f0151b
commit a9cea62d5b
3 changed files with 58 additions and 2 deletions

View file

@ -123,6 +123,21 @@ macro templated(filename)
end
get "/" do |env|
top = rank_videos(PG_DB, 120)
args = [] of String
1..(top.size - 1).times { |i| args << "($#{i + 1}), " }
args << "($#{top.size}) "
args = args.join("")
videos = [] of Video
PG_DB.query("SELECT * FROM videos d INNER JOIN (VALUES #{args}) v(id) USING (id)", top) do |rs|
rs.each do
video = rs.read(Video)
videos << video
end
end
templated "index"
end