Skip to content

Sohail: HGN Questionnaire Dashboard: Community Members (Filtered Members View)#2143

Merged
one-community merged 2 commits intodevelopmentfrom
Sohail-community-members-skill-filter
Apr 10, 2026
Merged

Sohail: HGN Questionnaire Dashboard: Community Members (Filtered Members View)#2143
one-community merged 2 commits intodevelopmentfrom
Sohail-community-members-skill-filter

Conversation

@sohailuddinsyed
Copy link
Copy Markdown
Contributor

@sohailuddinsyed sohailuddinsyed commented Mar 29, 2026

Description

Task: HGN Questionnaire Dashboard: Community Members (Filtered Members View)

Route: /hgnhelp/community
Related PR: PR 4214 -> 4503
Purpose: Displays community members with skill-based filtering.
Issue:

  • Team members are not displayed after clicking fliters. Shows failed to load members
  • Investigate and fix the backend API/endpoint used to retrieve team members (assign new developer if required).

The GET /api/hgnHelp/community endpoint was returning an empty result set whenever skill-based filters were used. Two bugs in communityController.js were identified as the cause:

  1. FormResponse.find() was called without .lean(), returning Mongoose documents instead of plain JS objects. Object.entries() on Mongoose subdocuments does not enumerate actual data fields, so extractSkills always produced empty objects, meaning no member ever matched a skill filter.
  2. Without proper key guards in extractSkills, internal Mongoose/MongoDB fields (prefixed with $ or _) could surface during enumeration and pollute the skill key list.

Related PRs (if any):

This backend PR is related to the development frontend branch.

Main changes explained:

  • Update src/controllers/communityController.js to add .lean() to the FormResponse.find() query so plain JS objects are returned, allowing Object.entries() to correctly enumerate skill fields.
  • Update src/controllers/communityController.js to add key guards in extractSkills that skip keys starting with $ or _, preventing internal fields from appearing in skill results.
  • Move extractSkills outside the .map() callback to avoid redefining the function on every iteration.

How to test:

  1. Check out branch fix/community-members-skill-filter
  2. Run npm install then start the server
  3. Clear site data/cache
  4. Log in as an admin user
  5. Navigate to /hgnhelp/community
  6. Apply one or more skill filters (e.g. React, MongoDB)
  7. Verify that matching community members are displayed in the list
  8. Verify that with no filters applied, all members are still shown
  9. Verify that the search and sortOrder query params still work as expected

Screenshots or videos of changes:

Before:
image

After:
Screenshot 2026-03-29 025723

@sonarqubecloud
Copy link
Copy Markdown

@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Mar 31, 2026
Copy link
Copy Markdown

@HemanthNidamanuru HemanthNidamanuru left a comment

Choose a reason for hiding this comment

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

Hi Sohail,

I tested this PR locally by following the steps above. Found a couple of issues:

  1. When no filters are applied, no members are showing at all. All members should be displayed by default.
  2. There is no sort option visible on the page anywhere. The sortOrder query param is mentioned in the test steps but there is no sorting control on the UI.

Could you please take a look at these?

Image Image Image Image

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 Sohail,

I have reviewed your PR locally and as mentioned by other reviewer, unable to see the default list of all members when no filters are selected and no sort order option is visible in frontend nor can any change be seen in Postman response.

Image Image Image Image Image Image

@sohailuddinsyed
Copy link
Copy Markdown
Contributor Author

@HemanthNidamanuru @Anusha-Gali
Thank you for your reviews. To address your concerns:

  • On sortOrder:

sortOrder was pre-existing in the original controller before this PR and was not introduced here. The backend supports it as a query param, but it looks like there is no sort UI on the frontend, it is effectively an unused param sitting in the API. Removing/adding it is out of scope for this bug fix and can be addressed in a separate task on the frontend.

  • On no members showing by default:

The backend already handles this correctly. When no skills query param is provided, skillFilters is an empty array and the endpoint returns all members from the HGNFormResponses collection. To confirm, hitting GET /api/hgnHelp/community with no query params should return all members. If nothing is showing on the page with no filters applied, the issue is in the frontend rendering logic, not this backend endpoint, and would need to be investigated in the related frontend PR.

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 Sohail,

Thank you for the update.

Image Image Image Image

@one-community
Copy link
Copy Markdown
Member

Thank you all, merging!

@one-community one-community merged commit 77c7423 into development Apr 10, 2026
3 checks passed
@rajanidi1999
Copy link
Copy Markdown

Hi,
I have reviewed your PR locally
image
image

Copy link
Copy Markdown

@rajanidi1999 rajanidi1999 left a comment

Choose a reason for hiding this comment

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

I’ve reviewed your PR, and it has been successfully executed. The implementation works as expected, and the overall structure is clean and well-organized. The feature integrates smoothly with the existing codebase, and the UI components appear consistent and responsive. I didn’t notice any major issues, though you might consider minor refinements for readability and consistency in naming. Overall, great job this is ready to be merged.

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.

5 participants