def post(self): parser = reqparse.RequestParser() parser.add_argument('this_budget', required=True, type=werkzeug.datastructures.FileStorage, location='files') args = parser.parse_args() this_file = request.files["this_budget"] this_json = this_file.read().replace("\n", "") this_target_category = request.form["this_target_category"] other_file = request.files["other_budget"] other_json = other_file.read().replace("\n", "") other_target_category = request.form["other_target_category"] start_date = request.form["start_date"] comparer = YnabBudgetComparer(this_json, this_target_category, other_json, other_target_category) comparer.set_start_date(start_date) missing_txns = comparer.get_missing_transactions() return {"this_missing": missing_txns[0], "other_missing": missing_txns[1]}
def post(self): method_start = time.clock() flask_app.logger.info("Comparing budgets") json = request.get_json() token = json['access_token'] this_budget_path = json['this_budget_path'] other_budget_path = json['other_budget_path'] db = Dropbox(token) start = time.clock() this_json = db.get_budget_file(this_budget_path) end = time.clock() elapsed = end - start flask_app.logger.debug("Get this budget time elapsed: {time}s".format(time=elapsed)) start = time.clock() other_json = db.get_budget_file(other_budget_path) end = time.clock() elapsed = end - start flask_app.logger.debug("Get other budget time elapsed: {time}s".format(time=elapsed)) this_target_category = json['this_target_category'] other_target_category = json['other_target_category'] start_date = json['comparison_start_date'] comparer = YnabBudgetComparer(this_json, this_target_category, other_json, other_target_category) comparer.set_start_date(start_date) start = time.clock() missing_txns = comparer.get_missing_transactions() end = time.clock() flask_app.logger.debug("Find missing transactions time elapsed: {time}s".format(time=(end - start))) method_finish = time.clock() method_elapsed = method_finish - method_start flask_app.logger.info("Finished comparing budgets. Time elapsed: {time}s".format(time=method_elapsed)) this_payees = comparer.get_this_payees() other_payees = comparer.get_other_payees() return {"this_missing": missing_txns[0], "other_missing": missing_txns[1], "this_payees": this_payees, "other_payees": other_payees}