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

Perspective field ordering bug #1109

Open
myrix opened this issue Mar 16, 2024 · 4 comments
Open

Perspective field ordering bug #1109

myrix opened this issue Mar 16, 2024 · 4 comments
Assignees
Labels
bug something doesn't work as expected. Has sub-labels: regression, backend, frontend, critical

Comments

@myrix
Copy link
Contributor

myrix commented Mar 16, 2024

Users report inability to change perspective field ordering.

Open https://lingvodoc.ispras.ru/dictionary/5576/1/perspective/5576/2/edit, click perspective dropdown menu, click Properties, click up arrow of the Cognates field, no effect.

Expected: Cognates field goes up in the list.

Looks like the problem is two fields having the same position ordering, open perspective properties looking at development -> network, see perspective -> columns GraphQL data:
image

So it seems when we try to exchange positions of these two fields, exchange of identical position values does nothing:
image

We need to:

  1. Look through backend and frontend sources and check everything relevant to how perspective field positions are assigned and changed, and fix any bugs that are present.

  2. Create an administrator only accessible mutation that for each perspective would check if the field ordering is valid, and if not fix it according to the current order of the fields in the interface.

    If the order is indetermined, ties can be broken via creation time and/or client id/object id numbers.

@myrix myrix added the bug something doesn't work as expected. Has sub-labels: regression, backend, frontend, critical label Mar 16, 2024
@vmonakhov
Copy link

vmonakhov commented Mar 20, 2024

Here is an anti-rating of perspectives with duplicate columns positions:

SELECT
dp.parent_client_id, dp.parent_object_id,
dp.client_id, dp.object_id,
(COUNT(position) - COUNT(DISTINCT position)) as twins
FROM 
dictionaryperspectivetofield as df,
dictionaryperspective as dp
WHERE
df.parent_client_id = dp.client_id and
df.parent_object_id = dp.object_id and
df.marked_for_deletion = 'false'
GROUP BY 
dp.parent_client_id, dp.parent_object_id,
dp.client_id, dp.object_id
ORDER BY twins DESC

изображение

vmonakhov added a commit to ispras/lingvodoc that referenced this issue Mar 20, 2024
* Correct sub_positions and next positions

* Refactoring

* Correct next field position
@vmonakhov
Copy link

On dictionary import (e.g. from .eaf) some fields are created with own sub-fields. In such cases sub-field's position iterator starts from '1' inspite of current position. So, sub-fields get already occupied positions and moreover next root-fields are counted up ignoring sub-fields.
This was solved in:
ispras/lingvodoc@85423a4

vmonakhov added a commit to ispras/lingvodoc that referenced this issue Mar 22, 2024
* reorder columns

* auto reordering

* fix

* comments
@vmonakhov
Copy link

Created graphql api for columns correct reordering. It can be run only with Administrator token.
Set concrete perspective_id to process one perspective, otherwise all found incorrect columns positions will be fixed.

curl 'https://lingvodoc.ispras.ru/api/graphql' \
    -H 'Content-Type: application/json' \
    -H 'Cookie: locale_id=2; auth_tkt=$TOKEN!userid_type:int; client_id=$ID' \
    --data-raw '{ "operationName": "reorder_columns", "variables": {"perspectiveId": null}, \
    "query": "mutation reorder_columns($perspectiveId: LingvodocID) \
    { reorder_columns(perspective_id: $perspectiveId, debug_flag: true) { triumph }}"}'

@vmonakhov
Copy link

Seems like all causes of duplicate columns positions within one perspective are solved. The main one is counting parent columns disregarding nested columns. So when a nested column becames parent one or conversely, correct ordering may be broken.

Now the corrective mutation and all related places in code generate through numeration of columns. So any column (parent or nested) within one perspective has unique position. The issue can be tested and closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something doesn't work as expected. Has sub-labels: regression, backend, frontend, critical
Projects
None yet
Development

No branches or pull requests

2 participants