List comprehensions are good, let's use them
This commit is contained in:
parent
813e1164c1
commit
d80166a420
|
@ -126,14 +126,13 @@ routes:
|
||||||
get "/search":
|
get "/search":
|
||||||
var
|
var
|
||||||
query = @"q".toLower
|
query = @"q".toLower
|
||||||
eps: seq[Episode]
|
|
||||||
|
|
||||||
if query == "":
|
if query == "":
|
||||||
halt Http406, myHeaders, $ %* { "error": "Need to specify query" }
|
halt Http406, myHeaders, $ %* { "error": "Need to specify query" }
|
||||||
|
|
||||||
for episode in episodes:
|
var
|
||||||
if episode.name.toLower.contains query:
|
eps: seq[Episode] =
|
||||||
eps = eps & episode
|
lc[x | (x <- episodes, x.name.toLower.contains query), Episode]
|
||||||
|
|
||||||
if eps.len == 0:
|
if eps.len == 0:
|
||||||
resp Http404, myHeaders, $ %* { "error": "No episodes found" }
|
resp Http404, myHeaders, $ %* { "error": "No episodes found" }
|
||||||
|
|
Loading…
Reference in New Issue