Erste funktionierende Version
This commit is contained in:
23
app.py
23
app.py
@@ -24,14 +24,25 @@ def index():
|
||||
|
||||
@app.route('/habits', methods=['GET'])
|
||||
def get_habits():
|
||||
habits_data = db.all()
|
||||
# Add completion status for the last 30 days
|
||||
raw_habits = db.all()
|
||||
formatted_habits = []
|
||||
last_30_days = get_last_30_days()
|
||||
for habit in habits_data:
|
||||
habit['completion_history'] = {}
|
||||
|
||||
for habit_doc in raw_habits:
|
||||
current_habit_data = {
|
||||
'id': habit_doc.doc_id,
|
||||
'name': habit_doc.get('name'),
|
||||
'completed_dates': habit_doc.get('completed_dates', [])
|
||||
}
|
||||
|
||||
completion_history = {}
|
||||
for date_str in last_30_days:
|
||||
habit['completion_history'][date_str] = date_str in habit.get('completed_dates', [])
|
||||
return jsonify(habits_data)
|
||||
completion_history[date_str] = date_str in current_habit_data['completed_dates']
|
||||
|
||||
current_habit_data['completion_history'] = completion_history
|
||||
formatted_habits.append(current_habit_data)
|
||||
|
||||
return jsonify(formatted_habits)
|
||||
|
||||
@app.route('/habits', methods=['POST'])
|
||||
def add_habit():
|
||||
|
||||
Reference in New Issue
Block a user