Fix API endpoints: Add GET /api/database/jobs/{job_id} and fix analytics dashboard authentication#36
Fix API endpoints: Add GET /api/database/jobs/{job_id} and fix analytics dashboard authentication#36joey-the-33rd wants to merge 14 commits into
Conversation
…_optional_current_user for /api/analytics and /analytics routes to allow public access to analytics data without requiring user login
…ation in DOMContentLoaded event listener to ensure DOM is fully loaded before executing JS, preventing stats from not displaying
…ager_fixed.js instead of database_manager.js to apply the DOM loading fix for stats display
…bManager globally and revert analytics to require authentication for security
…ics dashboard authentication
- Add get_job_by_id method to JobSearchStorage class
- Add GET /api/database/jobs/{job_id} endpoint to retrieve individual jobs
- Change analytics dashboard authentication from required to optional
- Fix 405 Method Not Allowed error for job retrieval by ID
- Fix 403 Forbidden error for analytics dashboard access
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
|||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
- Added /api/save-job endpoint to handle job saving requests - Implemented proper JSON serialization for datetime and dict objects - Added error handling and logging for job saving operations - Integrated with existing JobSearchStorage for database operations
- Enhanced the analytics dashboard HTML template - Improved CSS styling for better visual presentation - Updated layout structure for better user experience - Added proper responsive design elements
- Change api_save_job endpoint to use get_storage dependency injection
- Remove direct JobSearchStorage instantiation
- Add proper FastAPI route decorator @app.post('/api/save-job')
- Follow existing pattern used by other endpoints
- Add saved jobs statistics to overall analytics - Query user_job_interactions table for jobs with interaction_type = 'save' - Include total saved jobs and saved jobs this week metrics - Update default analytics structure to include saved_jobs
- Replace 'Growth Rate' card with 'Saved Jobs' card in dashboard - Update JavaScript to fetch and display saved jobs count from analytics API - Change icon from growth chart to bookmark icon for saved jobs - Update data extraction logic to handle saved_jobs statistics
- Document the plan and completed changes for PR code suggestions - Include summary of refactored API endpoint and analytics dashboard updates - Track testing results and implementation details
FastAPI dependencies for authentication
enhanced index html files
Add Login and Register Links to Enhanced Homepage Assign Images to StackScout Project
User description
This PR fixes two API endpoint issues identified in the application logs:
Changes Made
1. Added GET /api/database/jobs/{job_id} endpoint
2. Fixed analytics dashboard authentication
Testing
Related Issues
PR Type
Bug fix, Enhancement
Description
Add GET endpoint for retrieving individual jobs by ID (
/api/database/jobs/{job_id})Fix analytics dashboard authentication to allow optional user access
Implement DOM loading fix for database manager JavaScript initialization
Add auto-open job URL feature when viewing job details
Diagram Walkthrough
flowchart LR A["API Request"] --> B["GET /api/database/jobs/{job_id}"] B --> C["JobSearchStorage.get_job_by_id()"] C --> D["Return Job Data"] E["Analytics Dashboard"] --> F["Optional Authentication"] F --> G["Allow Public Access"] H["Database Manager JS"] --> I["DOMContentLoaded Wrapper"] I --> J["Initialize dbManager"]File Walkthrough
job_search_storage.py
Add job retrieval method to storage classjob_search_storage.py
get_job_by_id()method to retrieve specific job by IDformats
stackscout_web.py
Add job endpoint and fix analytics authenticationstackscout_web.py
/api/database/jobs/{job_id}endpoint for individual jobretrieval
database_manager_fixed.js
Fix DOM loading and add job URL auto-openstatic/js/database_manager_fixed.js
DatabaseManagerinitialization inDOMContentLoadedevent listenerdbManagerglobally to maintain event handler functionalitydatabase_manager_enhanced.html
Update template to use fixed JavaScript filetemplates/database_manager_enhanced.html
database_manager_fixed.jsinstead ofdatabase_manager.js