summaryrefslogtreecommitdiff
path: root/bin/fetch.fnl
diff options
context:
space:
mode:
authorunwox <me@unwox.com>2024-12-19 16:03:45 +0600
committerunwox <me@unwox.com>2024-12-19 16:13:42 +0600
commit441d7fd5a5a0ccf8d53238d717ec5119024cbbfa (patch)
tree0ab998dfaaddd0d6bcde9aa6d398364fc996531f /bin/fetch.fnl
parentd3a445ad7270e788812dd16e19a2820fc70a91b6 (diff)
parse teaware volume and let users filter by it
Diffstat (limited to 'bin/fetch.fnl')
-rw-r--r--bin/fetch.fnl8
1 files changed, 5 insertions, 3 deletions
diff --git a/bin/fetch.fnl b/bin/fetch.fnl
index 0551d76..a5f8d63 100644
--- a/bin/fetch.fnl
+++ b/bin/fetch.fnl
@@ -33,6 +33,7 @@
image TEXT NOT NULL,
price REAL NOT NULL,
weight REAL NOT NULL,
+ volume REAL NOT NULL,
price_per REAL NOT NULL,
archived BOOL NOT NULL,
creation_time DATETIME NOT NULL
@@ -102,7 +103,7 @@
(local sql
(.. "INSERT OR REPLACE INTO products VALUES "
(array.join
- (map (fn [_ _] "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
+ (map (fn [_ _] "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
products)
", ")))
(local creation-time (now))
@@ -118,6 +119,7 @@
(or product.image "")
(or product.price 0)
(or product.weight 0)
+ (or product.volume 0)
(or product.price-per 0)
(or product.archived false)
creation-time]))
@@ -152,8 +154,8 @@
;; replace with with-tx
(local tx (must (luna.db.begin db)))
(must (luna.db.exec-tx tx "DELETE FROM product_tags;" []))
-(each [_ parser (pairs [ozchai gorkovchay chaekshop clubcha artoftea ipuer
- moychay])]
+(each [_ parser (pairs [ozchai clubcha ipuer artoftea chaekshop moychay
+ gorkovchay])]
(store-products tx (parser.products)))
(cache.clear-tx tx "page:")
(must (luna.db.commit tx))