From defe4693186b38cefe3e19be1725272bb07c8b5d Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 28 May 2016 18:21:10 +0100 Subject: [PATCH] Track order insert date --- db.sql | 1 + lib/App/Web/Oof.pm | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/db.sql b/db.sql index eaff6f2..b753935 100644 --- a/db.sql +++ b/db.sql @@ -18,6 +18,7 @@ CREATE TABLE IF NOT EXISTS discounts ( CREATE TABLE IF NOT EXISTS orders ( id TEXT PRIMARY KEY, + date BIGINT NOT NULL, products JSON NOT NULL, total INT NOT NULL, discount VARCHAR(20) REFERENCES discounts UNIQUE, diff --git a/lib/App/Web/Oof.pm b/lib/App/Web/Oof.pm index c3aeeb1..69fcac3 100644 --- a/lib/App/Web/Oof.pm +++ b/lib/App/Web/Oof.pm @@ -213,7 +213,7 @@ sub order_app { die "Not enough of " .$prod->{title}."\n" if $prod->{quantity} > $stock; $db{$$}->update(products => {stock => $stock - $prod->{quantity}}, {product => $prod->{product}}); } - $db{$$}->insert(orders => {id => $id, %parms}); + $db{$$}->insert(orders => {id => $id, date => time, %parms}); $db{$$}->commit; sendmail (Email::Simple->create( header => [ -- 2.39.2