summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2015-08-16 16:57:25 +0200
committercos <cos>2015-08-16 16:57:25 +0200
commit5ad7d9d1b93a5cb0ece78086506dc054d9726e6e (patch)
tree7bfeff91ad4de9ca6c8383274e03323f5c652d04
parentb7592a14a91f6e3dea498c7b373969b43318d0b2 (diff)
parent6e251b43d508a43dc9a2eec7fbaa6c8e0abff598 (diff)
downloadmat-5ad7d9d1b93a5cb0ece78086506dc054d9726e6e.zip
Merge branch 'master' into debian
-rw-r--r--README8
-rwxr-xr-xmat28
2 files changed, 31 insertions, 5 deletions
diff --git a/README b/README
index 35a6b64..069ecfe 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
Mat is small a recipe management, food planning & lunch box inventory system.
-It was written with the aim to help me, who hates cooking, to be able to eat at
-regular intervals when working in an area with no decent restaurants.
+It was written with the aim to help me, who used to hate cooking*, to be able
+to eat at regular intervals when working in an area with no decent restaurants.
If for some obscure reason, you would like to use this hackish beast, the first
thing you need to do is create a sqlite database with the following schema:
@@ -21,6 +21,10 @@ CREATE TABLE cookings (recipe_id INTEGER, date DATETIME, specific_energy INTEGER
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".
+*) Now I actually quite fancy to cook, given that it is the creative & exciting
+ activity of trying out interesting recipes in the planned relaxed way that
+ this software enables me to it.
+
(Oh yeah! You might find the code quality & lack of design rubbish. That's
completely sane & so do I. I only ever code on this while also cooking. E.g.
when waiting for the stove & the oven to do its work.)
diff --git a/mat b/mat
index b0a309d..707a675 100755
--- a/mat
+++ b/mat
@@ -143,6 +143,8 @@ sub convert_to_unit {
$convert{'volume'} = $in_amount * 0.015;
} elsif ($in_unit eq "tsk") {
$convert{'volume'} = $in_amount * 0.005;
+ } elsif ($in_unit eq "krm") {
+ $convert{'volume'} = $in_amount * 0.001;
} elsif ($in_unit eq "g") {
$convert{'weight'} = $in_amount;
} elsif ($in_unit eq "kg") {
@@ -289,7 +291,7 @@ sub cmd_relocate {
sub cmd_inventory {
my ( $storage ) = @_;
- my $total = 0;
+ my %total;
my $sql = "SELECT recipe_id, count(recipe_id), storage FROM inventory";
$sql .= " WHERE storage='$storage'" if ( $storage );
@@ -297,15 +299,35 @@ sub cmd_inventory {
my $all = $db->selectall_arrayref($sql);
foreach my $row (@$all) {
- $total += @$row[1];
+ $total{'all'} += @$row[1];
+ $sql = "SELECT m.mealtype FROM typemap AS t JOIN mealtypes AS m ON ".
+ "t.mealtype_id=m.id WHERE t.recipe_id=".@$row[0]." ORDER by m.id;";
+ my $mealtypes = $db->selectcol_arrayref($sql);
printf "%3d x %s (%s)", @$row[1], get_recipe_name(@$row[0]), @$row[0];
+ foreach my $mealtype ( @$mealtypes ) {
+ if($mealtype eq $$mealtypes[0]) {
+ print " [" if($mealtype eq $$mealtypes[0]);
+ } else {
+ print " ";
+ }
+ print "$mealtype";
+ print "]" if($mealtype eq $$mealtypes[scalar(@$mealtypes)-1]);
+ $total{$mealtype} += @$row[1] / scalar(@$mealtypes);
+ }
if ( $storage ) {
print "\n";
} else {
print " ", @$row[2], "\n";
}
}
- printf "----\n%3d\n", $total;
+ printf "----\n%3d (", $total{'all'};
+ delete $total{'all'};
+ my $s = "";
+ foreach my $mealtype ( keys(%total) ) {
+ printf "$s%s %3d", $mealtype, $total{$mealtype};
+ $s = ', ';
+ }
+ printf ")\n";
}
sub cmd_randmeal {