Skip to content

Veda-Country-Map-Changes#1798

Open
Charitha2009 wants to merge 5 commits intodevelopmentfrom
veda-country-map-changes
Open

Veda-Country-Map-Changes#1798
Charitha2009 wants to merge 5 commits intodevelopmentfrom
veda-country-map-changes

Conversation

@Charitha2009
Copy link
Copy Markdown
Contributor

@Charitha2009 Charitha2009 commented Oct 10, 2025

Description

Implements Country Application Map Analytics API for the Job Posting Page Analytics feature.
This API enables aggregation, filtering, and comparison of applicant data by country, role, and time frame (weekly, monthly, yearly, or custom). The goal is to power the new world map visualization on the frontend dashboard by providing preprocessed data optimized for quick rendering and hover insights.

This feature allows admins to visualize global application trends, compare applicant growth between periods, and filter data by specific roles. Performance is enhanced through query optimization and optional caching for repeated analytical requests.

Related PRS (if any):

Frontend PR-#4195
Backend PR: This PR

Main changes explained:

  • Created new MongoDB schema (ApplicationAnalytics) to store country, role, applicants count, and timestamp for analytics.
  • Added new API endpoints for fetching applications, role-based filtering, and time-based comparisons (weekly, monthly, yearly).
  • Implemented aggregation logic using MongoDB pipelines to calculate applicant totals and percentage changes by country.
  • Integrated caching (Redis/in-memory) to optimize response time for frequently used filters.
  • Registered new routes and controller methods in analyticsRoutes.js and analyticsController.js for seamless frontend integration.

How to test:

  1. check into current branch
  2. do npm install and ... to run this PR locally
  3. Checkout branch & setup:

Screenshots or videos of changes:

Screenshot 2025-10-10 at 1 54 30 AM Screenshot 2025-10-10 at 1 48 59 AM 4581-82f1-01581b991eec" /> Screenshot 2025-10-10 at 1 49 25 AM Screenshot 2025-10-10 at 1 49 55 AM

- Added Application model for storing country-based job application data
- Implemented map analytics service with time-based filtering (weekly/monthly/yearly/all)
- Added role-based filtering with 24 professional job titles
- Created comparison data endpoints with percentage change calculations
- Implemented multi-tier caching system (analytics, static, general)
- Added REST API endpoints:
  * GET /api/analytics/country-applications - Main map data endpoint
  * GET /api/analytics/roles - Available roles for dropdown
  * GET /api/map-analytics/* - Extended analytics endpoints
- Updated middleware to allow public access to analytics endpoints
- Created seed script with 869 realistic application records
- Supports filtering by:
  * Time periods (WEEK, MONTH, YEAR, ALL)
  * Single or multiple roles
  * Custom date ranges
- Returns percentage changes for tooltips (e.g., +143.59% vs last week)
- All endpoints cached for optimal performance

Files modified: 7
Files added: 5
Copy link
Copy Markdown
Contributor

@harshavarma29 harshavarma29 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the PR in Postman using the Admin credentials and noticed the following issue:

All Filter Not Working: There is data available for the custom filter; however, when applying the All filter, the data is not getting grouped and instead displays as empty data.

backend-all-filter-not-working.mp4

Copy link
Copy Markdown

@IndraAnuraag9 IndraAnuraag9 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed this PR in Postman. For customs filters(roles, and dates), the data specific to them is displayed,
however, when trying to retrieve data for (All time, & All roles) and (role, weekly), it returns empty.

Screenshot 2025-10-24 at 8 35 59 PM Screenshot 2025-10-24 at 9 03 15 PM Screenshot 2025-10-24 at 9 04 25 PM Screenshot 2025-10-24 at 9 05 32 PM Screenshot 2025-10-24 at 9 06 25 PM Screenshot 2025-10-24 at 9 08 05 PM Screenshot 2025-10-24 at 9 08 34 PM

@Anusha-Gali Anusha-Gali added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Dec 11, 2025
Copy link
Copy Markdown

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Veda,

I have reviewed your PR locally and none of the API's work, only API that worked are the one i figured by looking at the API other reviewers used. Could you please update the correct API's used.
Screenshot 2025-12-10 at 8 14 56 PM
Screenshot 2025-12-10 at 8 15 02 PM
Screenshot 2025-12-10 at 8 15 04 PM
Screenshot 2025-12-10 at 8 15 07 PM

Test added 2 commits April 2, 2026 17:45
Resolve routes.js: keep map and country analytics with development job analytics and popularity routes. Regenerate package-lock.json after merge.

Made-with: Cursor
Copy link
Copy Markdown

@Anusha-Gali Anusha-Gali left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Veda,

Thank you for updating the API. Able to receive response for all.

Image Image Image Image

Test added 2 commits April 15, 2026 17:24
Use a same-duration previous custom window when filter range is custom so country analytics can compute comparison data for rolling date windows.

Made-with: Cursor
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
7 Security Hotspots

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants