ParthCodes commited on
Commit
018b21a
·
verified ·
1 Parent(s): 800cad1

Update controllers/mindmap.py

Browse files
Files changed (1) hide show
  1. controllers/mindmap.py +14 -0
controllers/mindmap.py CHANGED
@@ -60,6 +60,20 @@ def getMindmap(userId, savedMindmap):
60
  except Exception as e:
61
  print(e)
62
  return jsonify({"error": "An error occurred"}), 500
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
  def getMindmapByid(id, savedMindmap):
65
  try:
 
60
  except Exception as e:
61
  print(e)
62
  return jsonify({"error": "An error occurred"}), 500
63
+
64
+ def getMindmapHistory(userId, savedMindmap):
65
+ try:
66
+ results = savedMindmap.find({"userId": userId}).limit(3)
67
+ mindmaps = [{"_id": str(result["_id"]), "data": result["data"]} for result in results]
68
+
69
+ if mindmaps:
70
+ # Convert ObjectId to string for JSON serialization
71
+ return json_util.dumps({"data": mindmaps}), 200
72
+ else:
73
+ return jsonify({"msg": "No Mindmap stored"}), 404
74
+ except Exception as e:
75
+ print(e)
76
+ return jsonify({"error": "An error occurred"}), 500
77
 
78
  def getMindmapByid(id, savedMindmap):
79
  try: