You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[AWAITING CHECKLIST] [HOLD for payment 2024-12-12] [$250] Search-Order of the words is reversed when the query is submitted #52170
changed the title [-]Search-Order of the words is reversed when the query is submitted[/-][+][$250] Search-Order of the words is reversed when the query is submitted[/+]on Nov 7, 2024
What changes do you think we should make in order to solve the problem?
Instead of sorting the original query.flatFilters array inplace, we should create a new array where we sort the query.flatFilters.
Also, instead of using forEach we can map the query.flatFilters to a function so the original array is not mutated and orderedQuery parsed.
Optionally, I believe it is unnecessary to have two code snippets where we modify the query.flatFilters, seen below, to make orderedQuery so let's join the two code snippets into one.
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: Not critical but we can add test for it.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Go to the search page.
Click on the search bar.
Type in random letters or words preferably in reverse alphabetical order. E.g.: dog cat bird apple.
Press enter to search the keywords.
Check if the order of the keywords in the search bar is unchanged and exactly as you typed in Step 3.
Activity
melvin-bot commentedon Nov 7, 2024
Triggered auto assignment to @garrettmknight (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.[-]Search-Order of the words is reversed when the query is submitted[/-][+][$250] Search-Order of the words is reversed when the query is submitted[/+]melvin-bot commentedon Nov 7, 2024
Job added to Upwork: https://www.upwork.com/jobs/~021854577953623256419
melvin-bot commentedon Nov 7, 2024
Triggered auto assignment to Contributor-plus team member for initial proposal review - @rushatgabhane (
External)Tony-MK commentedon Nov 7, 2024
Edited by proposal-police: This proposal was edited at 2024-11-13 10:36:52 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
Search-Order of the words is reversed when the query is submitted.
What is the root cause of that problem?
The
SearchPageuses theSearchQueryUtils.buildSearchQueryJSONfunction to build a query.App/src/pages/Search/SearchPage.tsx
Lines 21 to 23 in b5c2c73
However, we end up sorting the
query.flatFilterswhich are the keywords by alphabetical order when calling thegetQueryHashesfunction.This is because a consistent hash function is needed.
App/src/libs/SearchQueryUtils.ts
Lines 272 to 274 in 494211d
What changes do you think we should make in order to solve the problem?
Instead of sorting the original
query.flatFiltersarray inplace, we should create a new array where we sort thequery.flatFilters.Also, instead of using
forEachwe canmapthequery.flatFiltersto a function so the original array is not mutated andorderedQueryparsed.Optionally, I believe it is unnecessary to have two code snippets where we modify the
query.flatFilters, seen below, to makeorderedQueryso let's join the two code snippets into one.App/src/libs/SearchQueryUtils.ts
Lines 238 to 240 in 494211d
App/src/libs/SearchQueryUtils.ts
Lines 242 to 245 in c24d217
nkdengineer commentedon Nov 8, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
The order of the words is reversed when the query is submitted.
What is the root cause of that problem?
Here is the function that we use to get the hash query. We have two sort functions here
App/src/libs/SearchQueryUtils.ts
Line 233 in 494211d
The first one is used to sort all values in a
filtersof a filterApp/src/libs/SearchQueryUtils.ts
Lines 238 to 241 in 494211d
The second one is used to sort all filters by key
App/src/libs/SearchQueryUtils.ts
Lines 242 to 245 in 494211d
For the case of this issue
TestandGare in the samefilterwith the key beingkeywordthen it's sorted by the first functionWhat changes do you think we should make in order to solve the problem?
I think for the
keywordkey filter, we should keep the order of all values. We can skip the sort function here if the key iskeywordApp/src/libs/SearchQueryUtils.ts
Lines 238 to 241 in 494211d
What alternative solutions did you explore? (Optional)
If we want to keep the order of all filters and all values of the filter we can remove these lines and the sort function here
melvin-bot commentedon Nov 11, 2024
@garrettmknight, @rushatgabhane Uh oh! This issue is overdue by 2 days. Don't forget to update your issues!
45 remaining items
garrettmknight commentedon Dec 17, 2024
@rushatgabhane please complete the checklist when you get a chance before submitting for payment.
garrettmknight commentedon Dec 21, 2024
@rushatgabhane can you complete the checklist when you get a chance?
garrettmknight commentedon Dec 30, 2024
Still awaiting the checklist
JmillsExpensify commentedon Dec 30, 2024
Confirming the payment summary:
garrettmknight commentedon Jan 7, 2025
Still awaiting checklist @rushatgabhane
rushatgabhane commentedon Jan 9, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: https://github.com/Expensify/App/pull/50883/files#r1908818356
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion: Not critical but we can add test for it.
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
Regression Test Proposal Template
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Precondition:
Test:
Do we agree 👍 or 👎
garrettmknight commentedon Jan 10, 2025
$250 approved for @rushatgabhane