summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcos <cos>2015-02-05 21:44:21 +0100
committercos <cos>2015-02-05 21:44:21 +0100
commit8640c0d3a7f3f6c26577cc26138db14f5f68364f (patch)
tree0754deef5b047c50c92ea780c9ab3b525007bc5b
parenta478c12859dfcad58da89758a94ba4c59a8ce1fd (diff)
downloadmat-8640c0d3a7f3f6c26577cc26138db14f5f68364f.zip
Skip prepared meals from shoppinglist.
-rwxr-xr-xmat32
1 files changed, 5 insertions, 27 deletions
diff --git a/mat b/mat
index 2a1cb16..993151b 100755
--- a/mat
+++ b/mat
@@ -741,40 +741,20 @@ sub cmd_shoppinglist {
$enddate->add(days => $shopdays);
-# First: Create a list of all meals from now to now+shopdays
-# Second: Divide each meal type with the ration size and apply the roof function
-# Third: Generate a list of all ingredients
-# Voila!
-
-# for (my $i = 0; $i < $shopdays; $i++) {
-# # FIXME Skip ingredients for ready or frozen recipes
-# print $i, "\n";
-# }
-
- my $plan_entries = $db->selectall_arrayref("SELECT recipe_id FROM plan WHERE recipe_id AND date ".
- "BETWEEN '".$startdate."' AND '".$enddate."' AND ".
- "IFNULL(state, 'null') != 'frozen' AND ".
- "IFNULL(state, 'null') != 'ready' AND ".
- "IFNULL(state, 'null') != 'sourced'", { Slice => {} });
+ my $plan_entries = $db->selectall_arrayref("SELECT recipe_id, date FROM plan WHERE recipe_id AND date ".
+ "BETWEEN '".$startdate."' AND '".$enddate."';", { Slice => {} });
my $queue_entries = $db->selectall_arrayref("SELECT recipe_id FROM queue;");
my %recipe_count;
for my $entry ( @$plan_entries ) {
- $recipe_count{$entry->{recipe_id}}++;
-# print $recipe_count{$entry->{recipe_id}}, " ", $entry->{recipe_id}, "\n";
-## print $entry->{recipe_id}."";
-## print " count: ", scalar(grep /$entry->{recipe_id}/, @$entries), " ";
-## print " count: ", $count{31}, "\n";
-## print " count: ", $count{$entry->{recipe_id}}, "\n";
-## # FIXME Take number of servings into account
-## TODO Loop through recipes to add ingredients to a list
-## TODO Print ingredients
+ if (get_plan_state($entry->{'recipe_id'}, $entry->{'date'}) ne "prepared") {
+ $recipe_count{$entry->{recipe_id}}++;
+ }
}
for my $entry ( @$queue_entries ) {
my @s = $db->selectrow_array("SELECT servings FROM queue WHERE ".
"recipe_id=@$entry[0]");
$recipe_count{@$entry[0]} += $s[0];
}
-# map {print "| $_ = ${recipe_count{$_}}\n"} sort keys(%recipe_count);
my @shop_recipes;
for my $recipe ( keys(%recipe_count) )
@@ -788,8 +768,6 @@ sub cmd_shoppinglist {
$servings = 1;
print "WARNING servings is not set for recipe $recipe!\n";
}
-# print "> $recipe", " ", $recipe_count{$recipe}, " ", $servings, "\n";
-# print "| $recipe", " ", ceiling($recipe_count{$recipe}/$servings), "\n";
my $cookings = ceiling($recipe_count{$recipe}/$servings);
for (my $i=0; $i < $cookings; $i++) {