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

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +29 -23
main.py CHANGED
@@ -599,8 +599,6 @@ def mindmapDemo():
599
  print(data)
600
  return get_initial_data(), 200
601
 
602
-
603
-
604
  @app.route('/roadmap', methods=['POST'])
605
  def roadmap():
606
  if request.method == 'POST':
@@ -725,7 +723,6 @@ Generate topics for all 7 days in a week and reference links only links(no heade
725
  # return jsonify({'success': True, 'roadmapData': roads_data_demo, 'activeDays': active_days})
726
 
727
 
728
-
729
  @app.route('/roadmapmodder', methods=['POST'])
730
  def roadmapmodder():
731
  if request.method == 'POST':
@@ -786,7 +783,11 @@ def roadmapmodder():
786
  )
787
 
788
  if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['year'] != day_data['year']:
789
- updateActiveStreak(obj_id, day_data)
 
 
 
 
790
 
791
  return jsonify({'success': True, 'youtubeUpdate': temp})
792
 
@@ -801,8 +802,12 @@ def roadmapmodder():
801
  {"$set": { "data": temp_data['data'] }}
802
  )
803
 
804
- if temp_data['activeDays'][len(temp_data['active_days'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['year'] != day_data['year']:
805
- updateActiveStreak(obj_id, day_data)
 
 
 
 
806
 
807
  return jsonify({'success': True})
808
 
@@ -817,8 +822,12 @@ def roadmapmodder():
817
  {"$set": { "data": temp_data['data'] }}
818
  )
819
 
820
- if temp_data['activeDays'][len(temp_data['active_days'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['year'] != day_data['year']:
821
- updateActiveStreak(obj_id, day_data)
 
 
 
 
822
 
823
  elif data.get('type') == 22: # Update Reference link Visit
824
  ref_link_index = data.get('refLinkIndex')
@@ -831,8 +840,12 @@ def roadmapmodder():
831
  {"$set": { "data": temp_data['data'] }}
832
  )
833
 
834
- if temp_data['activeDays'][len(temp_data['active_days'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['year'] != day_data['year']:
835
- updateActiveStreak(obj_id, day_data)
 
 
 
 
836
 
837
  # Add Mindmaps change in mindap generation fucntion such that if roadmapId, WeekNum, DayNum is sent while generation of mindmap then associate it directly with the roadmap.
838
 
@@ -845,21 +858,14 @@ def roadmapmodder():
845
  {"$set": { "data": temp_data['data'] }}
846
  )
847
 
848
- if temp_data['activeDays'][len(temp_data['active_days'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['year'] != day_data['year']:
849
- updateActiveStreak(obj_id, day_data)
 
 
 
 
850
 
851
  return jsonify({'success': True})
852
-
853
-
854
- def updateActiveStreak(object_id, day_data): # Update Active Streak
855
- temp_data = roadmap_collection.find_one({"_id": ObjectId(object_id)})
856
- temp_data['activeDays'].append(day_data)
857
-
858
- roadmap_collection.update_one(
859
- {"_id": ObjectId(object_id)},
860
- {"$set": { "activeDays": temp_data['activeDays'] }}
861
- )
862
-
863
 
864
 
865
  if __name__ == '__main__':
 
599
  print(data)
600
  return get_initial_data(), 200
601
 
 
 
602
  @app.route('/roadmap', methods=['POST'])
603
  def roadmap():
604
  if request.method == 'POST':
 
723
  # return jsonify({'success': True, 'roadmapData': roads_data_demo, 'activeDays': active_days})
724
 
725
 
 
726
  @app.route('/roadmapmodder', methods=['POST'])
727
  def roadmapmodder():
728
  if request.method == 'POST':
 
783
  )
784
 
785
  if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['year'] != day_data['year']:
786
+ temp_data['activeDays'].append(day_data)
787
+ roadmap_collection.update_one(
788
+ {"_id": ObjectId(obj_id)},
789
+ {"$set": { "activeDays": temp_data['activeDays'] }}
790
+ )
791
 
792
  return jsonify({'success': True, 'youtubeUpdate': temp})
793
 
 
802
  {"$set": { "data": temp_data['data'] }}
803
  )
804
 
805
+ if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['active_days'])-1]['year'] != day_data['year']:
806
+ temp_data['activeDays'].append(day_data)
807
+ roadmap_collection.update_one(
808
+ {"_id": ObjectId(obj_id)},
809
+ {"$set": { "activeDays": temp_data['activeDays'] }}
810
+ )
811
 
812
  return jsonify({'success': True})
813
 
 
822
  {"$set": { "data": temp_data['data'] }}
823
  )
824
 
825
+ if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['year'] != day_data['year']:
826
+ temp_data['activeDays'].append(day_data)
827
+ roadmap_collection.update_one(
828
+ {"_id": ObjectId(obj_id)},
829
+ {"$set": { "activeDays": temp_data['activeDays'] }}
830
+ )
831
 
832
  elif data.get('type') == 22: # Update Reference link Visit
833
  ref_link_index = data.get('refLinkIndex')
 
840
  {"$set": { "data": temp_data['data'] }}
841
  )
842
 
843
+ if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['year'] != day_data['year']:
844
+ temp_data['activeDays'].append(day_data)
845
+ roadmap_collection.update_one(
846
+ {"_id": ObjectId(obj_id)},
847
+ {"$set": { "activeDays": temp_data['activeDays'] }}
848
+ )
849
 
850
  # Add Mindmaps change in mindap generation fucntion such that if roadmapId, WeekNum, DayNum is sent while generation of mindmap then associate it directly with the roadmap.
851
 
 
858
  {"$set": { "data": temp_data['data'] }}
859
  )
860
 
861
+ if temp_data['activeDays'][len(temp_data['activeDays'])-1]['day'] != day_data['day'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['month'] != day_data['month'] or temp_data['activeDays'][len(temp_data['activeDays'])-1]['year'] != day_data['year']:
862
+ temp_data['activeDays'].append(day_data)
863
+ roadmap_collection.update_one(
864
+ {"_id": ObjectId(obj_id)},
865
+ {"$set": { "activeDays": temp_data['activeDays'] }}
866
+ )
867
 
868
  return jsonify({'success': True})
 
 
 
 
 
 
 
 
 
 
 
869
 
870
 
871
  if __name__ == '__main__':