Skip to content

Field Service Changes in Query#752

Merged
Shubham4026 merged 9 commits into
mainfrom
sdbv_rbac_changes
May 26, 2026
Merged

Field Service Changes in Query#752
Shubham4026 merged 9 commits into
mainfrom
sdbv_rbac_changes

Conversation

@Shubham4026
Copy link
Copy Markdown
Collaborator

@Shubham4026 Shubham4026 commented May 26, 2026

Summary by CodeRabbit

Release Notes

Improvements

  • Optimized custom field filtering for improved performance when filtering users by custom field criteria
  • Enhanced program image management in tenant configuration, providing better support for file uploads with improved merge behavior
  • Extended cohort membership event data to include detailed status information, enabling more comprehensive event tracking and monitoring

@gemini-code-assist
Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Caution

Review failed

Pull request was closed or merged during review

Walkthrough

This PR introduces three independent improvements: an optimized SQL-based custom-field filtering method, enhanced tenant program image handling with form-data parsing and merging, and enrichment of Kafka cohort event payloads with statusReason field for membership tracking.

Changes

Custom Field Filtering, Tenant Image Handling, and User Event Enrichment

Layer / File(s) Summary
Custom field filtering optimization
src/fields/fields.service.ts
New filterUserUsingCustomFieldsOptimized method replaces correlated EXISTS subqueries with parameterized JOINs across Cohort/Users, FieldValues, and Fields tables. Returns null for unsupported contexts or empty filters; otherwise selects distinct itemIds where field names, context variants, and FieldValues overlap via Postgres array operators. Original filterUserUsingCustomFields now delegates to this implementation.
Tenant program images form-data handling
src/tenant/tenant.controller.ts
updateTenants now parses programImages when provided as JSON string in multipart form-data, validates it as an array of strings, and throws BadRequestException on parse/validation failure. Uploaded file paths are merged into the programImages array alongside any pre-existing values instead of replacing them. Minor formatting changes to getTenants and deleteTenants method signatures.
Cohort statusReason in Kafka events
src/user/user.service.ts
Cohort-related Kafka event payload extended to include statusReason from cohort membership records. SQL query now selects cm."statusReason" and the mapping function includes this field in each cohorts array entry sent to kafkaService.publishUserEvent.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • tekdi/user-microservice#490: Modifies the same publishUserEvent cohort payload SQL and mapping path to add cohortMemberId, overlapping with this PR's statusReason addition.
  • tekdi/user-microservice#484: Adds contextType and related metadata to FieldValues, which aligns with the new filterUserUsingCustomFieldsOptimized method's context-matching logic.
  • tekdi/user-microservice#442: Implements the same filterUserUsingCustomFieldsOptimized refactor and delegation pattern in the fields service.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The pull request title 'Field Service Changes in Query' is vague and does not clearly convey the primary changes made across the three modified files. Provide a more specific title that captures the main optimization, such as 'Optimize custom field filtering with JOIN-based query' or 'Refactor field filtering and add programImages support'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sdbv_rbac_changes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@Shubham4026 Shubham4026 merged commit 0555daf into main May 26, 2026
2 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants