summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/serve.fnl9
1 files changed, 5 insertions, 4 deletions
diff --git a/bin/serve.fnl b/bin/serve.fnl
index 0c5ca6d..98e0aac 100644
--- a/bin/serve.fnl
+++ b/bin/serve.fnl
@@ -139,7 +139,7 @@
price_per AS \"price-per\",
year
FROM products
- ORDER BY RANDOM()
+ ORDER BY ROW_NUMBER() over (PARTITION BY site ORDER BY ROWID)
LIMIT ?"
[limit])))
@@ -186,7 +186,7 @@
(table.insert where-conds "products.price <= ?"))
(table.insert where-vars max-price))
- (local where-sql
+ (local where-sql
(if (< 0 (# where-conds))
(.. "AND " (array.join where-conds "\nAND "))
""))
@@ -209,7 +209,7 @@
(luna.db.query*
db
(string.format
- "SELECT highlight(search, 0, '<i>', '</i>') AS \"title\",
+ "SELECT products.title,
products.site,
products.description,
products.image,
@@ -225,7 +225,8 @@
LEFT JOIN product_tags ON product_tags.product = products.url
WHERE search.`table` = 'products'
%s
- ORDER BY rank
+ ORDER BY ROW_NUMBER() over (PARTITION BY products.site ORDER BY products.ROWID),
+ rank
LIMIT 48 OFFSET ?" where-sql)
(array.concat where-vars [(* (- page 1) 48)])))
:total (if (< 0 (# total))