def get(self): year = request.args.get("year") month = request.args.get("month") day = request.args.get("day") if year is None: return {"msg", "Please provide the year in the query param."}, 400 else: year = int(year) if len(year) > 0 else 0 if month is None: return ( {"msg", "Please provide the month in the query param."}, 400, ) else: month = int(month) if len(month) > 0 else 0 if day is None: day = 0 else: day = int(day) if len(day) > 0 else 0 entries = [] employee_ids = [row["id"] for row in Employee.get_employee_ids()] for _id in employee_ids: emp_entries = get_entries(_id, year, month, day) if len(emp_entries) > 0: entries.append(emp_entries) response = Response(generate(entries)) response.headers.set("Content-Disposition", "attachment", filename="export.csv") return response
def get(self): year = request.args.get("year") month = request.args.get("month") day = request.args.get("day") if year is None: return {"msg", "Please provide the year in the query param."}, 400 else: year = int(year) if len(year) > 0 else 0 if month is None: return ( {"msg", "Please provide the month in the query param."}, 400, ) else: month = int(month) if len(month) > 0 else 0 if day is None: day = 0 else: day = int(day) if len(day) > 0 else 0 entries = [] employee_ids = [row["id"] for row in Employee.get_employee_ids()] for _id in employee_ids: emp_entries = get_entries(_id, year, month, day) if len(emp_entries) > 0: entries.append(emp_entries) return {"entries": entries}, 200