summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-12-12 11:07:06 +0600
committerunwox <me@unwox.com>2024-12-16 21:20:55 +0600
commitb018944e6066e766560282c0bcd83df05899a4bc (patch)
tree5917e9a7b6b09dc6c097ac2f9633009e08759d81
parent155c9c5bbb703490e5d61f7b4504987e35088a95 (diff)
small fixes according to fennel-ls
-rw-r--r--bin/serve.fnl45
-rw-r--r--parser/artoftea.fnl2
2 files changed, 22 insertions, 25 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
diff --git a/parser/artoftea.fnl b/parser/artoftea.fnl
index 83ff0ea..265e19b 100644
--- a/parser/artoftea.fnl
+++ b/parser/artoftea.fnl
@@ -1,5 +1,3 @@
-(import-macros {: map} :lib.macro)
-
(local peg
(if (pick-values 1 (pcall require :lpeg))
(require :lpeg)