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