List comprehensions are good, let's use them
This commit is contained in:
parent
813e1164c1
commit
d80166a420
|
@ -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" }
|
||||
|
|
Loading…
Reference in New Issue