fix newest/last aired routes

This commit is contained in:
Christine Dodrill 2015-11-28 16:57:07 -08:00
parent f4bf5ebe0b
commit 8e92e1097e
1 changed files with 8 additions and 6 deletions

View File

@ -93,6 +93,10 @@ routes:
ep = episode
break
if ep.season == 0:
stats.newest.fails.inc
halt Http404, "No new episode found, haitus?"
stats.newest.success.inc
httpReply Http200, ep
@ -102,15 +106,13 @@ routes:
get "/last_aired":
var
now = getTime()
#now = getTime()
ep: Episode
for epid, episode in pairs[Episode](episodes):
var then = times.fromSeconds(episode.air_date)
if now < then:
ep = episodes[epid-1]
break
# XXX HACK PLEASE FIX
if episode.season == 5 and episode.episode == 26:
ep = episode
stats.lastAired.success.inc
httpReply Http200, ep