Spaces:
Sleeping
Sleeping
Commit ·
ab44078
1
Parent(s): 3801c91
Add system
Browse files239 unmodified lines2402412422432442451 unmodified line24724824925025125225325425525625725825926026126226326426526626726826927027127227327427511 unmodified lines287288289290291292239 unmodified linesfile_path = os.path.join(TMP_DIR, filename)pledge_date = data.get("pledge_date", "")pledge_author = data.get("pledge_author", "")if not os.path.exists(file_path):return jsonify({"error": "Event file not found"}), 4001 unmodified linewith open(file_path, "r") as f:events = json.load(f)# 直接存储反馈字符串值feedback_dict = {int(item['eventIndex']): item['answer'] for item in feedback_list}for idx, event in enumerate(events):event["user_feedback"] = feedback_dict.get(idx)log_entry = {"requested_time": data.get("timestamp"),"user_id": data.get("user_id"),"pledge": pledge,"pledge_author": pledge_author,"pledge_date": pledge_date,"events": events}timestamp = data.get("timestamp")user_id = data.get("user_id")if not user_id or not timestamp:return jsonify({'status': 'error', 'detail': 'Missing user_id or timestamp'}), 400local_filename = f"{FEEDBACK_DIR}/feedback_{timestamp}_{user_id}.jsonl"with open(local_filename, "w") as f:f.write(json.dumps(log_entry, indent=1))11 unmodified linesreturn jsonify({'status': 'success'})@app.route("/download-feedback/<filename>")def download_feedback_file(filename):return send_from_directory(FEEDBACK_DIR, filename, as_attachment=True)239 unmodified lines2402412422432442452462472482492501 unmodified line25225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628711 unmodified lines299300301302303304305239 unmodified linesfile_path = os.path.join(TMP_DIR, filename)pledge_date = data.get("pledge_date", "")pledge_author = data.get("pledge_author", "")timestamp = data.get("timestamp")user_id = data.get("user_id")if not user_id or not timestamp:return jsonify({'status': 'error', 'detail': 'Missing user_id or timestamp'}), 400if not os.path.exists(file_path):return jsonify({"error": "Event file not found"}), 4001 unmodified linewith open(file_path, "r") as f:events = json.load(f)suggestion_meta = Nonetime_start = Nonetime_end = Nonetry:prev_log_path = f"{FEEDBACK_DIR}/feedback_{timestamp}_{user_id}.jsonl"with open(prev_log_path, "r") as f:previous_log = json.load(f)suggestion_meta = previous_log.get("suggestion_meta")time_start = previous_log.get("time_start")time_end = previous_log.get("time_end")except Exception:passfeedback_dict = {int(item['eventIndex']): item['answer'] for item in feedback_list}for idx, event in enumerate(events):event["user_feedback"] = feedback_dict.get(idx)log_entry = {"requested_time": timestamp,"user_id": user_id,"pledge": pledge,"suggestion_meta": suggestion_meta,"time_start": time_start,"time_end": time_end,"pledge_author": pledge_author,"pledge_date": pledge_date,"events": events}local_filename = f"{FEEDBACK_DIR}/feedback_{timestamp}_{user_id}.jsonl"with open(local_filename, "w") as f:f.write(json.dumps(log_entry, indent=1))11 unmodified linesreturn jsonify({'status': 'success'})@app.route("/download-feedback/<filename>")def download_feedback_file(filename):return send_from_directory(FEEDBACK_DIR, filename, as_attachment=True)
app.py+24-11