Erste funktionierende Version

This commit is contained in:
jafreli
2025-07-16 18:43:11 +02:00
parent 08ed4906cc
commit c78e825f2f
5 changed files with 126 additions and 23 deletions

23
app.py
View File

@@ -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():