List comprehensions are good, let's use them

This commit is contained in:
Christine Dodrill 2015-08-14 14:20:54 -07:00
parent 813e1164c1
commit d80166a420
1 changed files with 3 additions and 4 deletions

View File

@ -126,14 +126,13 @@ routes:
get "/search":
var
query = @"q".toLower
eps: seq[Episode]
if query == "":
halt Http406, myHeaders, $ %* { "error": "Need to specify query" }
for episode in episodes:
if episode.name.toLower.contains query:
eps = eps & episode
var
eps: seq[Episode] =
lc[x | (x <- episodes, x.name.toLower.contains query), Episode]
if eps.len == 0:
resp Http404, myHeaders, $ %* { "error": "No episodes found" }