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')}")