File size: 3,701 Bytes
9e0d988
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
from dotenv import load_dotenv
from src.services.job_search_service import JobSearchService
from src.services.profile_service import ProfileService
from src.config import get_settings
import json
import os

# Load environment variables from .env file
load_dotenv()

# Debug: Check if Adzuna credentials are loaded
settings = get_settings()
print(
    f"πŸ” Debug - Adzuna App ID: {'βœ… Set' if settings.adzuna_app_id else '❌ Not set'}"
)
print(
    f"πŸ” Debug - Adzuna App Key: {'βœ… Set' if settings.adzuna_app_key else '❌ Not set'}"
)
print(f"πŸ” Debug - Adzuna Country: {settings.adzuna_country}")

# Environment variables check
print(
    f"πŸ” Debug - ADZUNA_APP_ID env: {'βœ… Set' if os.getenv('ADZUNA_APP_ID') else '❌ Not set'}"
)
print(
    f"πŸ” Debug - ADZUNA_APP_KEY env: {'βœ… Set' if os.getenv('ADZUNA_APP_KEY') else '❌ Not set'}"
)

# Initialize services
jb = JobSearchService()
profile_service = ProfileService()

# Create a sample user profile first (required for job search)
user_id = "test_user_001"
profile_data = {
    "skills": ["Python", "JavaScript", "React", "Node.js", "AWS"],
    "career_goals": "Software Engineer seeking remote opportunities in full-stack development",
    "location": "Remote",
    "resume": "Experienced software developer with 5+ years in web development, API design, and cloud platforms",
    "salary_wish": "$80,000 - $120,000",
}

# Create user profile
print("Creating user profile...")
profile_result = profile_service.upsert_profile(user_id, json.dumps(profile_data))
print(f"Profile created: {profile_result}")

# Search parameters
search_query = "software engineer"
location = "london"
job_type = "full-time"

print(f"\nπŸ” Searching for '{search_query}' jobs in '{location}' ({job_type})...")
print("=" * 60)

# Run job search (this will fetch from both Remotive and Adzuna)
search_results = jb.search_jobs(
    user_id=user_id, query=search_query, location=location, job_type=job_type
)

# Display results
if search_results.get("success"):
    jobs = search_results.get("jobs", [])
    total_found = search_results.get("total_found", 0)

    print(f"βœ… Found {total_found} jobs")
    print(f"πŸ“Š Search parameters: {search_results.get('search_params', {})}")

    # Group jobs by source
    remotive_jobs = [job for job in jobs if job.get("source") == "remotive"]
    adzuna_jobs = [job for job in jobs if job.get("source") == "adzuna"]
    sample_jobs = [job for job in jobs if job.get("source") == "sample"]

    print(f"\nπŸ“ˆ Results breakdown:")
    print(f"  β€’ Remotive jobs: {len(remotive_jobs)}")
    print(f"  β€’ Adzuna jobs: {len(adzuna_jobs)}")
    print(f"  β€’ Sample jobs: {len(sample_jobs)}")

    # Display top jobs from each source
    print(f"\nπŸ† TOP REMOTIVE JOBS:")
    print("-" * 40)
    for i, job in enumerate(remotive_jobs[:3], 1):
        print(f"{i}. {job['title']} at {job['company']}")
        print(f"   πŸ“ {job['location']}")
        print(f"   🎯 Fit Score: {job['fit_score']}%")
        print(f"   πŸ”— {job['url']}")
        print()

    print(f"\nπŸ† TOP ADZUNA JOBS:")
    print("-" * 40)
    for i, job in enumerate(adzuna_jobs[:3], 1):
        print(f"{i}. {job['title']} at {job['company']}")
        print(f"   πŸ“ {job['location']}")
        print(f"   🎯 Fit Score: {job['fit_score']}%")
        print(f"   πŸ”— {job['url']}")
        print()

    # Save detailed results to file
    with open("job_search_results.json", "w", encoding="utf-8") as f:
        json.dump(search_results, f, indent=2, default=str)

    print(f"πŸ’Ύ Detailed results saved to 'job_search_results.json'")

else:
    print(f"❌ Search failed: {search_results.get('message', 'Unknown error')}")