Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort by managed policy feature #950

Merged

Conversation

MansiShinde
Copy link
Contributor

@MansiShinde MansiShinde commented Dec 11, 2023

Description

Make managed by policy field sortable.
Fix unsupported operation exception error while sorting by Data stream field.
Ascending order
Screenshot 2023-12-11 at 3 23 28 PM

Descending order
Screenshot 2023-12-11 at 3 23 36 PM

Issues Resolved

List any issues this PR will resolve - 106 , 948

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>
Copy link

codecov bot commented Dec 11, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (03f268d) 63.37% compared to head (00de346) 63.37%.
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #950   +/-   ##
=======================================
  Coverage   63.37%   63.37%           
=======================================
  Files         341      341           
  Lines       11554    11554           
  Branches     2243     2243           
=======================================
  Hits         7322     7322           
  Misses       3658     3658           
  Partials      574      574           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

expand_wildcards?: string;
} = {
index: getSearchString(terms, indices, dataStreams),
format: "json",
s: `${sortField}:${sortDirection}`,
// s: `${sortField}:${sortDirection}`,
Copy link
Member

Choose a reason for hiding this comment

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

remove

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

Comment on lines 189 to 199
let flag;
const aManaged = a.managed as string;
const bManaged = b.managed as string;

if (sortDirection === "asc") {
flag = aManaged < bManaged;
} else {
flag = aManaged > bManaged;
}

return flag ? -1 : 1;
Copy link
Member

Choose a reason for hiding this comment

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

Extract this out as a function, can be reused. And this sort should only apply when sortField is "managed"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>
managed: managedStatus[catIndex.index] ? "Yes" : "No",
managedPolicy: managedStatus[catIndex.index],
})),
indices: customSort(
Copy link
Member

Choose a reason for hiding this comment

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

This sort on managed would only apply when the sortField is chosen to be managed as I understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello @bowenlan-amzn, thank you for bringing this to my attention. I noticed that the code was displaying indices based on the "managed" field, regardless of whether the sort field was "managed" or not. I have updated the logic, and it is now functioning as expected. Could you please take a look?

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>
Copy link
Member

@bowenlan-amzn bowenlan-amzn left a comment

Choose a reason for hiding this comment

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

Looks great to me!

@bowenlan-amzn bowenlan-amzn merged commit b516933 into opensearch-project:main Dec 12, 2023
11 of 12 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Dec 12, 2023
* sort by managed policy feature

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>

* add customSort function and remove comment

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>

* update managed by policy sorting logic

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>

---------

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>
(cherry picked from commit b516933)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
AWSHurneyt pushed a commit that referenced this pull request Dec 13, 2023
* sort by managed policy feature



* add customSort function and remove comment



* update managed by policy sorting logic



---------


(cherry picked from commit b516933)

Signed-off-by: Mansi Shinde <shinde.mansi55@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants