1818from PyMatcha .utils .decorators import debug_token_required
1919from PyMatcha .utils .decorators import validate_params
2020from PyMatcha .utils .errors import NotFoundError
21+ from PyMatcha .utils .populate_database import populate_users
2122from PyMatcha .utils .success import Success
2223from PyMatcha .utils .success import SuccessDeleted
24+ from PyMatcha .utils .tasks import update_user_recommendations
2325
2426debug_bp = Blueprint ("debug" , __name__ )
2527
@@ -72,13 +74,9 @@ def create_views(amount):
7274@debug_bp .route ("/debug/redis" )
7375@debug_token_required
7476def debug_show_redis ():
75- ret = {"users" : {}, "jtis" : {}}
76- for key in redis .scan_iter ("user:*" ):
77- value = redis .get (str (key ))
78- ret ["users" ][key ] = value
79- for key in redis .scan_iter ("jti:*" ):
80- value = redis .get (str (key ))
81- ret ["jtis" ][key ] = value
77+ ret = dict ()
78+ for key in redis .scan_iter ("*" ):
79+ ret [key ] = redis .get (str (key ))
8280 return jsonify (ret ), 200
8381
8482
@@ -135,7 +133,7 @@ def create_fake_like():
135133
136134@debug_bp .route ("/debug/tables" , methods = ["DELETE" ])
137135@debug_token_required
138- def delete_matches ():
136+ def delete_tables ():
139137 Match .drop_table ()
140138 Like .drop_table ()
141139 Report .drop_table ()
@@ -154,6 +152,13 @@ def delete_matches():
154152 return "" , 204
155153
156154
155+ @debug_bp .route ("/debug/redis" , methods = ["DELETE" ])
156+ @debug_token_required
157+ def delete_redis ():
158+ redis .flushdb ()
159+ return "" , 204
160+
161+
157162DEBUG_SEND_MESSAGE = {"from_uid" : str , "to_uid" : str , "content" : str }
158163
159164
@@ -166,3 +171,12 @@ def debug_send_message():
166171 to_id = get_user (data ["to_uid" ]).id
167172 Message .create (from_id = from_id , to_id = to_id , content = data ["content" ])
168173 return "" , 204
174+
175+
176+ @debug_bp .route ("/debug/recommendations/start" , methods = ["POST" ])
177+ @debug_token_required
178+ def debug_recommendations_start_process ():
179+ """This function will create 100 random users and calculate recommendations"""
180+ populate_users (amount = 100 , drop_user_table = False )
181+ update_user_recommendations ()
182+ return Success ("Done" )
0 commit comments