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

Empty attribute values should be sorted consistently #563

Open
4 tasks
benel opened this issue Mar 10, 2022 · 3 comments
Open
4 tasks

Empty attribute values should be sorted consistently #563

benel opened this issue Mar 10, 2022 · 3 comments

Comments

@benel
Copy link
Member

benel commented Mar 10, 2022

Description

What is the valuable outcome that cannot be achieved because of this bug?

For which stakeholder (people, role, project, domain) is it important?

Reproduction scenario

Steps to reproduce the behavior:

  1. Go to the "vitraux" portfolio
  2. Sort by spatial
  3. Several items with no attribute value are among others (especially "SPSP ???").

Expected behavior

They should be either at the beginning or at the end of the list.

Workaround

Solution you found to avoid the problem.

Deliverables status

Phase 1

  • Scenarios (Gherkin)
  • Implementation strategy

Phase 2

  • Acceptance tests (Capybara)
  • Implementation
@benel benel added the Fix label Mar 10, 2022
@benel
Copy link
Member Author

benel commented Mar 25, 2022

Stratégie de développement de la correction

Localisation du problème

Le tri des items est effectué dans le composant Corpora de la page Portfolio.
Plus précisément il est invoqué à la ligne 18 et défini à la ligne 15 :

  sort = memoize((items, criteria) => items.sort(by(`${criteria}.0`)));
  • by correspond à la fonction de comparaison importée de la bibliothèque compare-fun,
  • items est un tableau.

@benel
Copy link
Member Author

benel commented Mar 25, 2022

Simulation in vitro du problème

Testé sur RunKit.

Avec des valeurs nulles :

const by = require('compare-func');

[
    {name:'A', creator:'2'}, 
    {name:'D', creator:null}, 
    {name:'C', creator:'1'}, 
    {name:'B', creator:null}
].sort(by('creator'))
Array (4 items)
0: Object {name: "D", creator: null}
1: Object {name: "B", creator: null}
2: Object {name: "C", creator: "1"}
3: Object {name: "A", creator: "2"}
length: 4
Array Prototype

Avec des valeurs indéfinies :

const by = require('compare-func');

[
    {name:'A', creator:'2'}, 
    {name:'D'}, 
    {name:'C', creator:'1'}, 
    {name:'B'}
].sort(by('creator'))
Array (4 items)
0: Object {name: "A", creator: "2"}
1: Object {name: "D"}
2: Object {name: "C", creator: "1"}
3: Object {name: "B"}
length: 4
Array Prototype

@benel
Copy link
Member Author

benel commented Mar 25, 2022

Avec des tableaux (comme dans le code de Porphyry).

const by = require('compare-func');

[
    {name:'A', creator:['Moi']}, 
    {name:'D'}, 
    {name:'C', creator:['Lui']}, 
    {name:'B'}
].sort(by('creator.0'))
Array (4 items)
0: Object {name: "A", creator: ["Moi"]}
1: Object {name: "D"}
2: Object {name: "C", creator: ["Lui"]}
3: Object {name: "B"}
length: 4
Array Prototype

Ne fonctionne ni avec null ni avec [], ni avec [null]. Fonctionne par contre avec [""].

const by = require('compare-func');

[
    {name:'A', creator:['Moi']}, 
    {name:'D', creator:['']}, 
    {name:'C', creator:['Lui']}, 
    {name:'B', creator:['']}
].sort(by('creator.0'))
Array (4 items)
0: Object {name: "D", creator: [""]}
1: Object {name: "B", creator: [""]}
2: Object {name: "C", creator: ["Lui"]}
3: Object {name: "A", creator: ["Moi"]}
length: 4
Array Prototype

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants