Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
e5dbd556
Commit
e5dbd556
authored
7 years ago
by
Atte Keinänen
Browse files
Options
Downloads
Patches
Plain Diff
Fix sorting with remapped values
parent
5bdac956
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/selectors/metadata.js
+7
-4
7 additions, 4 deletions
frontend/src/metabase/selectors/metadata.js
with
7 additions
and
4 deletions
frontend/src/metabase/selectors/metadata.js
+
7
−
4
View file @
e5dbd556
...
...
@@ -159,7 +159,6 @@ const patchBooleanFieldValues_HACK = (valueArray) => {
// We want that we have a distinct selector for each field id combination, and for that reason
// we export a method that creates a new selector; see
// https://github.com/reactjs/reselect#sharing-selectors-with-props-across-multiple-components
// TODO Atte Keinänen 7/20/17: How should this work for remapped values?
// TODO Atte Keinänen 7/20/17: Should we have any thresholds if the count of field values is high or we have many (>2?) fields?
export
const
makeGetMergedParameterFieldValues
=
()
=>
{
return
createFieldValuesEqualSelector
(
getParameterFieldValuesByFieldId
,
(
fieldValues
)
=>
{
...
...
@@ -172,10 +171,14 @@ export const makeGetMergedParameterFieldValues = () => {
const
singleFieldValues
=
fieldValues
[
fieldIds
[
0
]]
return
patchBooleanFieldValues_HACK
(
singleFieldValues
);
}
else
{
const
sortedMergedValues
=
_
.
flatten
(
Object
.
values
(
fieldValues
),
true
).
sort
()
const
sortedMergedValues
=
_
.
chain
(
Object
.
values
(
fieldValues
))
.
flatten
(
true
)
// Use remapped value for sorting if it is available
.
sortBy
(
fieldValue
=>
fieldValue
.
length
===
2
?
fieldValue
[
1
]
:
fieldValue
[
0
])
.
value
()
// run the uniqueness comparision always against a non-remapped value
// we can use `isSorted = true` flag to speed up _.uniq as we just sorted the values
return
_
.
uniq
(
sortedMergedValues
,
true
,
(
fieldValue
)
=>
fieldValue
[
0
]);
return
_
.
uniq
(
sortedMergedValues
,
false
,
(
fieldValue
)
=>
fieldValue
[
0
]);
}
});
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment