File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -195,19 +195,20 @@ def get_recommendations(request: SkillRequest):
195195 position_id = user .get ("position" )
196196 position = database .get_collection ("positions" ).find_one ({"_id" : position_id }, {"name" : 1 })
197197 position_name = position ["name" ] if position and position .get ("name" ) else None
198+ print (position_name )
198199
199200 # 1. matching skills, FURTHER IMPROVEMENT: maybe we can use AI to match some typo skills
200201 start_time = time .time ()
201202 skill_ids = user .get ("skills" , [])
202203 skills = list (database .get_collection ("skills" ).find ({"_id" : {"$in" : skill_ids }}, {"name" : 1 }))
203204 user_skills = [clean_skills_name (skill ["name" ]) for skill in skills ]
204- required_skills = [clean_skills_name (skill ) for skill in position_with_skills [ position_name ] ]
205-
205+ required_skills = [clean_skills_name (skill ) for skill in position_with_skills . get ( position_name , []) ]
206+
206207 matched_count = len (set (required_skills ) & set (user_skills ))
207208 total = len (set (required_skills ))
208209 print ("Yang cocok: " , matched_count )
209210 print ("Butuh brp: " , total )
210- matched_count_score = matched_count / total
211+ matched_count_score = 0.0 if total == 0 else matched_count / total
211212 print ("Required skills: " , required_skills )
212213 print ("User skills: " , user_skills )
213214 logs ["skill_matching_time" ] += time .time () - start_time
You can’t perform that action at this time.
0 commit comments