Add /last_aired route

For @ask-compu
This commit is contained in:
Christine Dodrill 2015-08-17 14:32:05 -07:00
parent 24ef6f4c69
commit b5d36da2b6
2 changed files with 19 additions and 0 deletions

View File

@ -64,6 +64,11 @@ objects as defined above.
Returns the episode of My Little Pony: Friendship is Magic that will air next.
### `/last_aired`
Returns the episode of My Little Pony: Friendship is Magic that most recently
aired.
### `/season/<number>`
Returns all information about episodes in the given season number or a `404`

View File

@ -85,6 +85,20 @@ routes:
get "/random":
resp Http200, myHeaders, pretty(%%episodes.randomChoice(), 4)
get "/last_aired":
var
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
resp Http200, myHeaders, pretty(%%ep, 4)
get "/season/@snumber":
var
season: int = @"snumber".parseInt