diff options
| author | unwox <me@unwox.com> | 2024-12-12 11:07:06 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-12-16 21:20:55 +0600 |
| commit | b018944e6066e766560282c0bcd83df05899a4bc (patch) | |
| tree | 5917e9a7b6b09dc6c097ac2f9633009e08759d81 /bin/serve.fnl | |
| parent | 155c9c5bbb703490e5d61f7b4504987e35088a95 (diff) | |
small fixes according to fennel-ls
Diffstat (limited to 'bin/serve.fnl')
| -rw-r--r-- | bin/serve.fnl | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/bin/serve.fnl b/bin/serve.fnl index 9329bf1..ea75edd 100644 --- a/bin/serve.fnl +++ b/bin/serve.fnl @@ -6,14 +6,13 @@ (local fennel (require :vendor.fennel)) (local html (require :vendor.html)) (local libhtml (require :lib.html)) -(local json (require :vendor.json)) (local array (require :lib.array)) (local str (require :lib.string)) (local texts (require :texts)) (local fs (require :lib.fs)) (local spellfix (require :lib.spellfix)) (local cache (require :lib.cache)) -(local {: must : measure} (require :lib.utils)) +(local {: must} (require :lib.utils)) (when _G.unpack (tset table :unpack _G.unpack)) @@ -36,7 +35,8 @@ (tset old k nil))) (tset package :loaded module old)))))) -(local db (must (luna.db.open "file:var/db.sqlite?_journal=WAL&_sync=NORMAL"))) +(local db + (must (luna.db.open "file:var/db.sqlite?_journal=WAL&_sync=NORMAL&mode=ro"))) (local query-synonyms { "шэн" "шен" @@ -182,34 +182,34 @@ db "SELECT DISTINCT tags.title FROM tags INNER JOIN product_tags ON product_tags.tag = tags.title - ORDER BY creation_time" - [])))) + ORDER BY creation_time" [])))) (fn shops-count [] - (# (must (luna.db.query db - "SELECT DISTINCT site - FROM products - WHERE archived = false" [])))) + (# (must (luna.db.query db + "SELECT DISTINCT site + FROM products + WHERE archived = false" [])))) (fn products-count [] - (. (must (luna.db.query db - "SELECT DISTINCT COUNT(url) - FROM products - WHERE archived = false" [])) - 1 1)) + (. (must (luna.db.query db + "SELECT DISTINCT COUNT(url) + FROM products + WHERE archived = false" [])) + 1 1)) (fn latest-update-date [] - (. (must - (luna.db.query db - "SELECT creation_time FROM products ORDER BY creation_TIME DESC LIMIT 1" - [])) - 1 1)) + (. (must (luna.db.query db + "SELECT creation_time + FROM products + ORDER BY creation_TIME DESC + LIMIT 1" [])) + 1 1)) (fn query-products [{: query : tags : min-price : max-price : price-per : site : sort} page] (local tags (or tags [])) - - (var where-conds []) - (var query-args []) + (local where-conds []) + (local sort-criteria []) + (local query-args []) ;; create WHERE clause from dynamic form parameters (when (< 0 (# tags)) @@ -246,7 +246,6 @@ "")) ;; create SORT clause from dynamic form parameters - (var sort-criteria []) (when sort (if (= sort "cheap-first") (table.insert sort-criteria |
