-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_sorting.py
More file actions
83 lines (70 loc) · 3.53 KB
/
debug_sorting.py
File metadata and controls
83 lines (70 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python3
"""
Debug script to check keyword match count sorting
"""
import requests
import json
def debug_sorting():
"""Debug the sorting issue"""
base_url = "http://localhost:8080"
# Test the jobs API endpoint
try:
print("Testing jobs API...")
response = requests.get(f"{base_url}/jobs/api/jobs", timeout=5)
if response.status_code == 200:
data = response.json()
print(f"✅ Jobs API working - {len(data.get('jobs', []))} jobs returned")
else:
print(f"⚠️ Jobs API status: {response.status_code}")
except Exception as e:
print(f"❌ Jobs API error: {e}")
# Test the recommendations endpoint (this will likely require auth)
try:
print("\nTesting recommendations API...")
response = requests.get(f"{base_url}/jobs/api/all-jobs-with-recommendations", timeout=5)
if response.status_code == 200:
data = response.json()
print(f"✅ Recommendations API working")
print(f" - Total jobs: {data.get('total_jobs', 0)}")
print(f" - Recommended count: {data.get('recommended_count', 0)}")
print(f" - User keywords: {len(data.get('user_keywords', []))}")
# Check keyword match counts
jobs = data.get('all_jobs', [])
if jobs:
print(f"\n📊 Keyword Match Count Analysis:")
print(f" - Total jobs with data: {len(jobs)}")
# Count jobs by keyword match count
match_counts = {}
for job in jobs:
count = job.get('keyword_match_count', 0)
match_counts[count] = match_counts.get(count, 0) + 1
print(f" - Jobs by keyword match count:")
for count in sorted(match_counts.keys(), reverse=True):
print(f" {count} matches: {match_counts[count]} jobs")
# Check first few jobs to see their order
print(f"\n🔍 First 5 jobs (checking order):")
for i, job in enumerate(jobs[:5]):
print(f" {i+1}. {job.get('job_title', 'Unknown')[:50]}...")
print(f" - Keyword matches: {job.get('keyword_match_count', 0)}")
print(f" - Is recommended: {job.get('is_recommended', False)}")
print(f" - Posted: {job.get('posted_at', 'Unknown')}")
# Check if keyword_match_count field exists
sample_job = jobs[0]
if 'keyword_match_count' in sample_job:
print(f"\n✅ keyword_match_count field is present")
else:
print(f"\n❌ keyword_match_count field is MISSING")
print(f" Available fields: {list(sample_job.keys())}")
elif response.status_code == 401:
print("⚠️ Recommendations API requires authentication")
else:
print(f"⚠️ Recommendations API status: {response.status_code}")
except Exception as e:
print(f"❌ Recommendations API error: {e}")
print("\n🔧 Debugging Steps:")
print("1. Check if backend is returning keyword_match_count")
print("2. Check if frontend is receiving the data correctly")
print("3. Check if sorting logic is working")
print("4. Check if there are any JavaScript errors in browser console")
if __name__ == "__main__":
debug_sorting()