huridocs / uwazi

Uwazi is a web-based, open-source solution for building and sharing document collections
http://www.uwazi.io
MIT License
242 stars 80 forks source link

[IX] Incorrect logic for Has Context suggestion property #7060

Closed RafaPolit closed 3 months ago

RafaPolit commented 3 months ago

https://github.com/huridocs/uwazi/blob/8357473abfc2af54d979601b050e4a01fa4ece6a/app/shared/getIXSuggestionState.ts#L114-L122

This logic is not correct. hasContext is no necessarily true if it's a select or multiselect according to @txau

@gabriel-piles can you please explain what should be the logic to define if hasContext should be true? Thanks.

txau commented 3 months ago

Moreover, there is a mess with how and when no context is being reported:

image

You can clearly see in the list there are 2 suggestions with "No context", but the filter panel shows "0 no context".

Also, some suggestions show the context when folded and others don't, it is unclear what it means.

gabriel-piles commented 3 months ago

@RafaPolit The service's suggestions include a property named 'segment_text' which provides the context. And it could happen to have empty context and a multi-option/text suggestion in some scenarios.

txau commented 3 months ago

@gabriel-piles if I am understanding correctly, the code is saying "if it is a thesaurus or relationship field, the value of hasContext is always going to be true".

I understand this is coming from some methods not defining a context. Maybe we need to make sure that all methods define a context, even if it is not a particular segment, but an explanation such as "Based on the first 500 words of the document".

txau commented 3 months ago

Apparently this is more of a front-end issue than a back-end.

The logic is correct according to @gabriel-piles and context can be an empty string (it depends on the method selected in the service), but the front-end needs to respect the flag from the back-end, so the two lines saying "No context" in the table seem to be wrong, it should display blank as the others.

txau commented 3 months ago

After a conversation with Gabriel we decided to remove the business logic from the backend and frontend and leave it to the service to decide what the context is going to be. Meaning, both backend and frontend need to account to what the segmentvariable contains and remove the exception for the "isSelect" and "isRelationship" condition.

RafaPolit commented 3 months ago

@txau should we close this in favor of #7085 ?