Need Help fixing my code!! only under TODO's. // Util function to convert a FoodWastageReport class object into a serialized // JSON object. crow::json::wvalue FoodWastageReportToCrowJSON(     const FoodWastageReport &report) {   crow::json::wvalue report_json({});   std::vector most_common_disposal_mechanisms{};   // TODO 1: Call the member function of FoodWastageReport class that returns   // all the most common disposal mechanisms as a vector of strings. Store the   // result in the vector declared above.   FoodWastageReport report;   std::vector most_common_disposal_mechanisms = report.MostCommonDisposalMechanisms();   report_json["most_common_disposal_mechanism_"] =       most_common_disposal_mechanisms;   std::vector most_commonly_wasted_foods{};   // TODO 2: Call the member function of FoodWastageReport class that returns   // all the most commonly wasted foods as a vector of strings. Store the result   // in the vector declared above.   std::vector most_commonly_wasted_foods = report.MostCommonlyWastedFoods();   report_json["most_commonly_wasted_food_"] = most_commonly_wasted_foods;   std::vector most_common_wastage_reasons{};   // TODO 3: Call the member function of FoodWastageReport class that returns   // all the most commonwastage reasons as a vector of strings. Store the result   // in the vector declared above.   std::vector most_common_wastage_reasons = report.MostCommonWastageReasons();   report_json["most_common_wastage_reason_"] = most_common_wastage_reasons;   std::vector most_costly_waste_producing_meals{};   // TODO 4: Call the member function of FoodWastageReport class that returns   // all the most costly waste producing meals as a vector of strings. Store the   // result in the vector declared above.   std::vector most_costly_waste_producing_meals = report.MostCostlyWasteProducingMeals();   report_json["most_waste_producing_meal_"] = most_costly_waste_producing_meals;   std::vector suggested_strategies_to_reduce_waste{};   // TODO 5: Call the member function of FoodWastageReport class that returns   // all the suggested strategies as a vector of strings. Store the result in   // the vector declared above.   std::vector suggested_strategies_to_reduce_waste = report.SuggestWasteReductionStrategies();   report_json["suggested_strategies_to_reduce_waste_"] =       suggested_strategies_to_reduce_waste;   double total_cost_of_wastage = -9999.0;

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

Need Help fixing my code!! only under TODO's.

// Util function to convert a FoodWastageReport class object into a serialized
// JSON object.
crow::json::wvalue FoodWastageReportToCrowJSON(
    const FoodWastageReport &report) {
  crow::json::wvalue report_json({});

  std::vector<std::string> most_common_disposal_mechanisms{};
  // TODO 1: Call the member function of FoodWastageReport class that returns
  // all the most common disposal mechanisms as a vector of strings. Store the
  // result in the vector declared above.
  FoodWastageReport report;
  std::vector<std::string> most_common_disposal_mechanisms = report.MostCommonDisposalMechanisms();
  report_json["most_common_disposal_mechanism_"] =
      most_common_disposal_mechanisms;

  std::vector<std::string> most_commonly_wasted_foods{};
  // TODO 2: Call the member function of FoodWastageReport class that returns
  // all the most commonly wasted foods as a vector of strings. Store the result
  // in the vector declared above.
  std::vector<std::string> most_commonly_wasted_foods = report.MostCommonlyWastedFoods();
  report_json["most_commonly_wasted_food_"] = most_commonly_wasted_foods;

  std::vector<std::string> most_common_wastage_reasons{};
  // TODO 3: Call the member function of FoodWastageReport class that returns
  // all the most commonwastage reasons as a vector of strings. Store the result
  // in the vector declared above.
  std::vector<std::string> most_common_wastage_reasons = report.MostCommonWastageReasons();
  report_json["most_common_wastage_reason_"] = most_common_wastage_reasons;

  std::vector<std::string> most_costly_waste_producing_meals{};
  // TODO 4: Call the member function of FoodWastageReport class that returns
  // all the most costly waste producing meals as a vector of strings. Store the
  // result in the vector declared above.
  std::vector<std::string> most_costly_waste_producing_meals = report.MostCostlyWasteProducingMeals();
  report_json["most_waste_producing_meal_"] = most_costly_waste_producing_meals;

  std::vector<std::string> suggested_strategies_to_reduce_waste{};
  // TODO 5: Call the member function of FoodWastageReport class that returns
  // all the suggested strategies as a vector of strings. Store the result in
  // the vector declared above.
  std::vector<std::string> suggested_strategies_to_reduce_waste = report.SuggestWasteReductionStrategies();
  report_json["suggested_strategies_to_reduce_waste_"] =
      suggested_strategies_to_reduce_waste;

  double total_cost_of_wastage = -9999.0;
  // TODO 6: Call the member function of FoodWastageReport class that returns
  // the total cost of wastage as a double. Store the result in the double
  // declared.
  double total_cost_of_wastage = report.TotalCostOfFoodWasted();
  report_json["total_cost_of_food_wasted_"] = total_cost_of_wastage;

  return report_json;
}

// Util function to convert a crow query string into a FoodWastageRecord class
// object.
FoodWastageRecord QueryStringToFoodWastageRecord(
    const crow::query_string &query_string) {
  FoodWastageRecord record;

  // TODO 1. Get the date from the query_string using query_string.get("date"),
  // and set it in the `record` object using the setter in FoodWastageRecord
  // class.
  std::string date = query_string.get("date");
  record.SetDate(date);

  // TODO 2. Get the meal from the query_string using query_string.get("meal"),
  // and set it in the `record` object using the setter in FoodWastageRecord
  // class.
  std::string meal = query_string.get("meal");
  record.SetMeal(meal);

  // TODO 3. Get the food name from the query_string using
  // query_string.get("food_name"), and set it in the `record` object using the
  // setter in FoodWastageRecord class.
  std::string food_name = query_string.get("food_name");
  record.SetMeal(food_name);

  // TODO 4. Get the quantity from the query_string using
  // std::stod(query_string.get("qty_in_oz")), and set it in the `record` object
  // using the setter in FoodWastageRecord class.
  double quantity = std::stod(query_string.get("qty_in_oz"));
  record.SetQuantityInOz(quantity);

  // TODO 5. Get the wastage reason from the query_string using
  // query_string.get("wastage_reason"), and set it in the `record` object using
  // the setter in FoodWastageRecord class.
  std::string wastage_reason = query_string.get("wastage_reason");
  record.SetWastageReason(wastage_reason);

  // TODO 6. Get the disposal mechanism from the query_string using
  // query_string.get("disposal_mechanism"), and set it in the `record` object
  // using the setter in FoodWastageRecord class.
  std::string disposal_mechanism = query_string.get("disposal_mechanism");
  record.SetDisposalMechanism(disposal_mechanism);

  // TODO 7. Get the cost from the query_string using
  // std::stod(query_string.get("cost")), and set it in the `record` object
  // using the setter in FoodWastageRecord class.
  double cost = std::stod(query_string.get("cost"));
  record.SetCost(cost);

  return record;
}

1 #include "food_wastage_tracker_backend.h"
HN
2
3
#include <filesystem>
4
5
#include "food_wastage_record.h"
6 #include "food_wastage_report.h"
7 #include "server_utils/rapidjson/document.h"
8 #include "server_utils/rapidjson/prettywriter.h"
9 #include "server_utils/rapidjson/rapidjson.h"
10 #include "server_utils/rapidjson/stringbuffer.h" // wrapper of C stream for prettywriter as output
#include "server_utils/rapidjson/writer.h"
11
// rapidjson's DOM-style API
// for stringify JSON
Transcribed Image Text:1 #include "food_wastage_tracker_backend.h" HN 2 3 #include <filesystem> 4 5 #include "food_wastage_record.h" 6 #include "food_wastage_report.h" 7 #include "server_utils/rapidjson/document.h" 8 #include "server_utils/rapidjson/prettywriter.h" 9 #include "server_utils/rapidjson/rapidjson.h" 10 #include "server_utils/rapidjson/stringbuffer.h" // wrapper of C stream for prettywriter as output #include "server_utils/rapidjson/writer.h" 11 // rapidjson's DOM-style API // for stringify JSON
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps

Blurred answer
Knowledge Booster
Types of Linked List
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education