Skip to content

[OSDEV-1493] Moderation. Moderation Queue Page (integration) - sorting issue and 500 error for localization#451

Merged
roman-stolar merged 6 commits intomainfrom
OSDEV-1493-mq-country-sort-issue
Dec 13, 2024
Merged

[OSDEV-1493] Moderation. Moderation Queue Page (integration) - sorting issue and 500 error for localization#451
roman-stolar merged 6 commits intomainfrom
OSDEV-1493-mq-country-sort-issue

Conversation

@roman-stolar
Copy link
Contributor

@roman-stolar roman-stolar commented Dec 11, 2024

OSDEV-1493 Moderation. Moderation Queue Page (integration) - sorting issue and 500 error for localization

  • Fixed an issue where the backend sorts countries not by name but by their alpha-2 codes in GET /api/v1/moderation-events/ endpoint.

… their `alpha-2 codes` in `GET /api/v1/moderation-events/` endpoint.
@roman-stolar roman-stolar self-assigned this Dec 11, 2024
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:34 — with GitHub Actions Inactive
@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:36 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Dec 11, 2024

React App | Jest test suite - Code coverage report

Total: 27.88%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@coderabbitai
Copy link

coderabbitai bot commented Dec 11, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The pull request introduces a new release section for version 1.27.0 in the RELEASE-NOTES.md file, detailing various categories of changes, including specific bug fixes related to invalid date handling and sorting countries in the moderation events API. Additionally, it modifies the add_sort method in the ModerationEventsQueryBuilder class to change the sorting criteria for countries from alpha-2 codes to name. The release instructions have also been updated to include necessary post-deployment commands.

Changes

File Change Summary
doc/release/RELEASE-NOTES.md Added new release section for version 1.27.0, including introduction, categories of changes, and bugfix for OSDEV-1492 and OSDEV-1493. Retained previous release notes for version 1.26.0.
src/django/api/views/v1/opensearch_query_builder/moderation_events_query_builder.py Modified add_sort method in ModerationEventsQueryBuilder to sort countries by name instead of alpha-2 codes.
src/django/api/tests/test_moderation_events_query_builder.py Added test_add_sort_country method to test sorting functionality for the country field in the query builder.

Possibly related PRs

Suggested reviewers

  • vladsha-dev
  • Innavin369
  • mazursasha1990
  • VadimKovalenkoSNF

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8f8d046 and a929a40.

📒 Files selected for processing (1)
  • src/django/api/tests/test_moderation_events_query_builder.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/django/api/tests/test_moderation_events_query_builder.py

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. (Experiment)
  • @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.

@roman-stolar roman-stolar temporarily deployed to Quality Environment December 11, 2024 14:41 — with GitHub Actions Inactive
@barecheck
Copy link

barecheck bot commented Dec 11, 2024

Dedupe Hub App | Unittest test suite - Code coverage report

Total: 56.14%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Dec 11, 2024

Countries App | Unittest test suite - Code coverage report

Total: 100%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

@barecheck
Copy link

barecheck bot commented Dec 11, 2024

Contricleaner App | Unittest test suite - Code coverage report

Total: 98.91%

Your code coverage diff: 0.00% ▴

✅ All code changes are covered

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

🧹 Outside diff range and nitpick comments (1)
doc/release/RELEASE-NOTES.md (1)

23-24: Consider adding more details about the fixed issues.

The bugfix entries would benefit from additional context:

  • For OSDEV-1493: Explain the impact of sorting by alpha-2 codes vs names
  • For OSDEV-1492: Describe what caused the 500 error and how it was fixed
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8c3851e and 5c2161f.

📒 Files selected for processing (1)
  • doc/release/RELEASE-NOTES.md (1 hunks)
🔇 Additional comments (4)
doc/release/RELEASE-NOTES.md (4)

Line range hint 1-7: LGTM! The release notes header follows best practices.

The header section properly documents:

  • Project versioning scheme (Semantic Versioning)
  • Template usage
  • File purpose

Line range hint 9-13: LGTM! The release metadata is complete.

The introduction section properly includes:

  • Product name
  • Release date

Line range hint 1-1024: LGTM! Version numbering follows semantic versioning.

The release history demonstrates consistent use of semantic versioning:

  • Major version (1.x.x) for backwards-incompatible changes
  • Minor version (x.22.x to x.27.x) for new features
  • Patch version (x.x.1, x.x.2) for hotfixes

Line range hint 26-29: Verify the post-deployment commands.

The release instructions mention two commands:

  • migrate
  • reindex_database

Please verify that these commands are sufficient and no additional steps are needed.

✅ Verification successful

Let me analyze the post_deployment.py command to verify what commands it runs.


The release notes accurately reflect the required post-deployment commands

The post_deployment command in the codebase executes exactly the two commands mentioned in the review:

  • migrate
  • reindex_database

These commands are sufficient as they handle both database schema updates and reindexing operations, which are the critical steps needed after deployment.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any additional migration or indexing commands in recent commits

# Search for any new migration files
fd -e py -p ".*_[0-9]{4}_.*\.py$" | grep -i "migrations"

# Search for management commands that might need to be run
rg -A 5 "class Command\(BaseCommand\)" 

Length of output: 16365


Script:

#!/bin/bash
# Check the implementation of post_deployment command
cat src/django/api/management/commands/post_deployment.py

Length of output: 498

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

🧹 Outside diff range and nitpick comments (3)
doc/release/RELEASE-NOTES.md (3)

Line range hint 1-24: Update the release date to a past date.

The release date is set to December 28, 2024, which is a future date. Release notes should document past releases.

## Introduction
* Product name: Open Supply Hub
- * Release date: December 28, 2024
+ * Release date: December 19, 2023

21-24: Consider adding more details to the bugfix descriptions.

The bugfix entries would benefit from additional context about the impact and resolution:

### Bugfix
- * [OSDEV-1492](https://opensupplyhub.atlassian.net/browse/OSDEV-1492) - Fixed an issue where invalid manually entered dates were not validated on the UI, resulting in API errors with message "The request query is invalid." on `Moderation Queue` page. Invalid dates are now trimmed and properly handled.
- * [OSDEV-1493](https://opensupplyhub.atlassian.net/browse/OSDEV-1493) - Fixed an issue where the backend sorts countries not by `name` but by their `alpha-2 codes` in `GET /api/v1/moderation-events/` endpoint.
+ * [OSDEV-1492](https://opensupplyhub.atlassian.net/browse/OSDEV-1492) - Fixed date validation on the Moderation Queue page
+   - Issue: Invalid manually entered dates were not validated on the UI, causing API errors with "The request query is invalid"
+   - Resolution: Added client-side validation to trim and properly handle invalid dates
+   - Impact: Users no longer encounter API errors when entering dates
+ * [OSDEV-1493](https://opensupplyhub.atlassian.net/browse/OSDEV-1493) - Fixed country sorting in moderation events
+   - Issue: Countries were sorted by alpha-2 codes instead of names in GET /api/v1/moderation-events/
+   - Resolution: Updated sorting to use country names
+   - Impact: Improved readability of country listings in moderation events

Line range hint 26-30: Consider formatting release instructions as a checklist.

The release instructions would be clearer as a checklist format:

### Release instructions:
- * Ensure that the following commands are included in the `post_deployment` command:
-     * `migrate`
-     * `reindex_database`
+ Please complete the following steps in order:
+ - [ ] Ensure the `post_deployment` command includes:
+   - [ ] `migrate` - Apply database migrations
+   - [ ] `reindex_database` - Rebuild search indexes
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5c2161f and bc2e1d8.

📒 Files selected for processing (1)
  • doc/release/RELEASE-NOTES.md (1 hunks)

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

🧹 Outside diff range and nitpick comments (1)
src/django/api/tests/test_moderation_events_query_builder.py (1)

91-94: LGTM! The test correctly validates the country sorting behavior.

The test effectively verifies that countries are now sorted by name instead of alpha-2 codes, which aligns with the PR objectives.

Consider adding these test cases for completeness:

def test_add_sort_country_desc(self):
    self.builder.add_sort('country', 'desc')
    expected = {'cleaned_data.country.name': {'order': 'desc'}}
    self.assertIn(expected, self.builder.query_body['sort'])

def test_add_sort_country_no_longer_uses_alpha_2(self):
    self.builder.add_sort('country', 'asc')
    unexpected = {'cleaned_data.country.alpha_2': {'order': 'asc'}}
    self.assertNotIn(unexpected, self.builder.query_body['sort'])
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between bc2e1d8 and 8f8d046.

📒 Files selected for processing (1)
  • src/django/api/tests/test_moderation_events_query_builder.py (1 hunks)

@roman-stolar
Copy link
Contributor Author

@VadimKovalenkoSNF @vladsha-dev Ready for re-review

vladsha-dev
vladsha-dev previously approved these changes Dec 13, 2024
Copy link
Contributor

@vladsha-dev vladsha-dev left a comment

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud
Copy link

Copy link
Contributor

@vladsha-dev vladsha-dev left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@VadimKovalenkoSNF VadimKovalenkoSNF left a comment

Choose a reason for hiding this comment

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

LGTM.

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.

3 participants