Skip to content

[OSDEV-1748] Align SLC with current v1/production-locations validation.#520

Merged
VadimKovalenkoSNF merged 3 commits intomainfrom
OSDEV-1748-align-slc-with-v1-production-location-validation
Feb 18, 2025
Merged

[OSDEV-1748] Align SLC with current v1/production-locations validation.#520
VadimKovalenkoSNF merged 3 commits intomainfrom
OSDEV-1748-align-slc-with-v1-production-location-validation

Conversation

@Innavin369
Copy link
Contributor

@Innavin369 Innavin369 commented Feb 17, 2025

OSDEV-1748 Moderation Queue. Align SLC with current v1/production-locations validation.

  • changed func parseContribData (removed all not filled fields)
  • removed validation for number_of_workers min >= max

…ask description, removed validation for number_of_workers min>=max
@Innavin369 Innavin369 self-assigned this Feb 17, 2025
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:03 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:05 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Feb 17, 2025

React App | Jest test suite - Code coverage report

Total: 29.6%

Your code coverage diff: 0.09% ▴

✅ All code changes are covered

@coderabbitai
Copy link

coderabbitai bot commented Feb 17, 2025

📝 Walkthrough

Walkthrough

This pull request updates the project’s release notes for version 2.0.0 and introduces several changes across the database schema, API endpoints, and frontend utility functions. A new database field (action_perform_by) is added via a migration, and the GET /api/v1/production-locations/ endpoint now supports geo-bounding box queries with defined validation rules. Additionally, the validation method in the NumberOfWorkersSerializer was removed, and the client-side parseContribData function was refactored. Architecture changes include splitting the Django container and removing certain Terraform variables.

Changes

File(s) Change Summary
doc/release/RELEASE-NOTES.md
.../0166_add_moderationevent_action_perform_by.py
Added a new release entry for 2.0.0; documented the new action_perform_by field in api_moderationevent, geo-bounding box query support for GET /api/v1/production-locations/, removal of the min-max validation for number_of_workers, architectural updates, and miscellaneous bug fixes.
src/django/api/serializers/v1/number_of_workers_serializer.py Removed the validate method from the NumberOfWorkersSerializer class that enforced a minimum less-than-maximum check for the number_of_workers field.
src/react/src/util/util.js Refactored the parseContribData function to iterate over required fields using a loop and helper functions (extractProductionLocationContributionValues and generateRangeField), thereby improving code readability and maintainability.
src/react/src/__tests__/utils.tests.js Introduced a new function parseContribData and modified generateRangeField to enhance data processing capabilities and improve handling of various input types.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API_Server as API Server
    participant Database
    Client->>API_Server: GET /api/v1/production-locations?bbox=...
    API_Server->>API_Server: Validate geo-bounding box parameters
    API_Server->>Database: Query production locations within bounding box
    Database-->>API_Server: Return matching records
    API_Server-->>Client: Respond with filtered location data
Loading

Possibly related PRs

Suggested reviewers

  • roman-stolar
  • mazursasha1990
  • vladsha-dev
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:10 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Feb 17, 2025

Dedupe Hub App | Unittest test suite - Code coverage report

Total: 56.14%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:11 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 19:11 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Feb 17, 2025

Contricleaner App | Unittest test suite - Code coverage report

Total: 98.91%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Feb 17, 2025

Countries App | Unittest test suite - Code coverage report

Total: 100%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 20:11 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 21:29 — with GitHub Actions Inactive
@Innavin369 Innavin369 temporarily deployed to Quality Environment February 17, 2025 21:46 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Feb 17, 2025

Django App | Unittest test suite - Code coverage report

Total: 80.44%

Your code coverage diff: 0.04% ▴

✅ All code changes are covered

@sonarqubecloud
Copy link

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/react/src/util/util.js (1)

1458-1477: LGTM! Clean refactor with improved field handling.

The changes effectively:

  • Remove unfilled fields
  • Transform field values consistently
  • Handle number_of_workers and country fields appropriately

A minor suggestion to improve readability:

-    const { numberOfWorkers, country, ...fields } = contribData;
+    const { 
+        numberOfWorkers,
+        country,
+        ...fields 
+    } = contribData;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1664bb4 and 52d771a.

📒 Files selected for processing (1)
  • src/react/src/util/util.js (3 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/react/src/util/util.js (1)
Learnt from: VadimKovalenkoSNF
PR: opensupplyhub/open-supply-hub#470
File: src/react/src/util/util.js:1441-1472
Timestamp: 2025-01-29T09:00:01.638Z
Learning: The data passed to parseContribData() function in src/react/src/util/util.js is pre-parsed and validated before reaching the function, so additional type checking is not required.
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: run-integration-test-code-quality
  • GitHub Check: run-flake8-linter
  • GitHub Check: run-fe-code-quality
  • GitHub Check: run-eslint-linter-and-prettier-formatter
  • GitHub Check: run-django-code-quality
  • GitHub Check: run-dd-code-quality
  • GitHub Check: run-countries-code-quality
  • GitHub Check: run-contricleaner-code-quality
  • GitHub Check: get-base-branch-fe-cov
  • GitHub Check: get-base-branch-dd-cov
  • GitHub Check: get-base-branch-django-cov
  • GitHub Check: get-base-branch-countries-cov
  • GitHub Check: get-base-branch-contricleaner-cov
🔇 Additional comments (2)
src/react/src/util/util.js (2)

1437-1442: LGTM! Robust implementation for handling both array and non-array inputs.

The function safely extracts values from both array and non-array inputs, with proper null-safety using optional chaining.


1454-1454: LGTM! Ensures consistent number type output.

The modification ensures that both min and max values are properly converted to numbers, maintaining type consistency.

Copy link
Contributor

@roman-stolar roman-stolar left a comment

Choose a reason for hiding this comment

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

LGTM
@VadimKovalenkoSNF @Innavin369 One question, so from now user could put any data to number_of_workers and it will be parsed by rules in generateRangeField method but no exception will be raised? Is it correct scenario?

@VadimKovalenkoSNF
Copy link
Contributor

@roman-stolar In case of SLC we have FE validation.

@roman-stolar
Copy link
Contributor

Got it!

Copy link
Contributor

@mazursasha1990 mazursasha1990 left a comment

Choose a reason for hiding this comment

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

Approved

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.

4 participants