din-co / d2

Solidus-based commerce application
0 stars 2 forks source link

Create SubscriptionOrderManager to generate subscription selections #327

Closed cee-dub closed 8 years ago

cee-dub commented 8 years ago

Fire up a console on the production application:

$ heroku run bin/rails console -a din-marketplace

Generate and print out subscription selections:

# After orders for the preceding week have been created for Monday subscribers, create the
# subscription manager with stock for Monday.
# Use exact name from admin products.
# Sort products in order of desired recommendation.
mgr = SubscriptionOrderManager.from_meal_names({
  "Calabrian Antipasti" => 15,
  "Seared Idaho Trout" => 25,
  "Chitarra alla Puttanesca & Sturgeon Conserva" => 20,
  "A16’s Monday Meatballs" => 15,
  "Cornmeal Cakes with Roasted Broccoli Rabe" => 25,
  "Little Gem Salad with Farm Egg" => 25,
  "Coconut Turmeric Curry" => 5,
  "Ginger Lemongrass Chicken" => 10,
  "Maranella Pinsa & Insalata Mista" => 10,
  "Margherita Pinsa & Rapette Salad" => 10,
})
# Generate and print selections from available meals for Monday subscribers.
mgr.print_selections(Spree::MealSubscription.monday)

Repeat for Tuesday by creating a new manager after Tuesday orders have been placed for the preceding week, and hand in the Tuesday subscriptions: Spree::MealSubscription.tuesday

beausmith commented 8 years ago

LGTM