summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2014-01-18 14:59:28 +0100
committercos <cos>2014-01-18 14:59:28 +0100
commit9a9ccd11e0fe68232cc605f9bfdd883f4c0afe4f (patch)
tree24cea60d497fa07b656e232679aae4c9a73dbfb0
parent3e7f9000c6868549b1b9cf8d447aa30bb54624f8 (diff)
downloadmat-9a9ccd11e0fe68232cc605f9bfdd883f4c0afe4f.zip
Store preparation dates in inventory table.
-rw-r--r--README2
-rw-r--r--TODO4
-rwxr-xr-xmat5
3 files changed, 4 insertions, 7 deletions
diff --git a/README b/README
index 6ec033e..d556444 100644
--- a/README
+++ b/README
@@ -10,7 +10,7 @@ CREATE TABLE ingredients (id INTEGER PRIMARY KEY AUTOINCREMENT, name, shop_posit
CREATE TABLE contents (recipe_id INTEGER, ingredient_id INTEGER, quantity FLOAT, unit);
CREATE TABLE plan (date DATETIME, mealtype, recipe_id INTEGER, state, comment_id);
CREATE TABLE comments (id INTEGER PRIMARY KEY AUTOINCREMENT, comment);
-CREATE TABLE inventory (id INTEGER PRIMARY KEY AUTOINCREMENT, recipe_id INTEGER, amount INTEGER, storage);
+CREATE TABLE inventory (id INTEGER PRIMARY KEY AUTOINCREMENT, recipe_id INTEGER, preparation_date DATETIME, amount INTEGER, storage);
All basic operations are performed using the perl script mat. It is possible to
get a crude list of commands available by running: "mat help".
diff --git a/TODO b/TODO
index 8d2d091..c311f18 100644
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
- * Add a README file describing how to use this stuff. Include an sql schema.
-
* Replace currently cooking with a planned queue of meals.
* Implement web thingy to view & relocate portions.
@@ -7,8 +5,6 @@
* Combine into one row on the shoppinglist when there are several entries of
the same ingredient.
- * Store preparation dates in inventory table.
-
* Add command to feedback when portions were too small (still hungry/ate five
chocolate bars after lunch) or too large (became full/lunch took two hours
to complete).
diff --git a/mat b/mat
index 9ee730a..2f103db 100755
--- a/mat
+++ b/mat
@@ -346,8 +346,9 @@ sub print_label {
sub cmd_storeportion {
my ( $recipe_id, $amount, $storage ) = @_;
- my $sql = "INSERT INTO inventory (recipe_id, amount, storage ) VALUES (".
- "$recipe_id, $amount, '$storage' );";
+ my $sql = "INSERT INTO inventory (recipe_id, preparation_date, amount, ".
+ "storage ) VALUES ($recipe_id, ".`date +%Y%m%d|tr -d '\n'`.", $amount, ".
+ "'$storage' );";
$db->do($sql);
my $inventory_id = $db->last_insert_id(undef, undef, undef, undef);