nicHoch / tca

app bug reporting
4 stars 0 forks source link

Tags are not inherited #96

Closed killakalle closed 3 years ago

killakalle commented 3 years ago

What happened? Parents' tags are not inherited by their children areas. But they should be.

Example url(s) to reproduce the problem: Has no tags while parent has tags

Open El Elefante (Artificial) in theCrag powered Topo Guru app! https://thecrag.topoguru.com/info/3067857549 Ideally also provide screenshots: Screenshot_20210408_232710_com topoguru

What you expected:

rouletout commented 3 years ago

See inherting rules here: https://www.thecrag.com/en/article/tagging

andrasbari commented 3 years ago

When I request a node like this: https://www.thecrag.com/api/index/detail/2912905038?withdata=NodeID%2CParentID%2CLastUpdated%2CNodeType%2CAreaType%2CName%2CDepth%2CSiblingSequence%2CCountryNodeID%2CTLC%2CPoint%2CBoundedBox%2CFence%2CNumberRoutes%2CStyles%2CWebcover%2CURL%2CAlternateName%2CNumberAscents%2CSeasonality%2CTag%2CDescription%2CHistory%2CGearStyle%2CNumberTopos%2CGrade%2CBandProfile%2CAscentBandProfile%2CGhosts%2CPopularity%2CKudos%2CTopo%2CGradeContribution%2CRegisteredGrades%2CPitches%2CBolts%2CHeight&to=leaf&markupType=html&cacheable=1&pretty=1&abbr=0&topoidonly=0&webcover-dimensions=%5B%5B1080%2C720%5D%2C%5B540%2C360%5D%2C%5B192%2C192%5D%5D&key=abcd

I receive this for tag ids: `

    [
        198053161,
        198053143,
        198053137,
        198053101,
        198053095,
        198053131,
        2274064242
     ]

`

for eg.: tag with 198053095 id is not have inherit flag so it is not inheritable: `

  {
     "appliesTo" : {
        "Areas" : 1
     },
     "categoryKey" : "",
     "categoryLabel" : "",
     "categoryName" : null,
     "icon" : "/static/cids/images/tag-icons_drinking-water-1.1.0.png",
     "id" : 198053095,
     "tagKey" : "drinking-water",
     "tagLabel" : "Drinking water",
     "tagName" : "Drinking water",
     "themeKey" : "comfort",
     "themeLabel" : "Comfort",
     "themeName" : "Comfort",
     "typeKey" : "amenities",
     "typeLabel" : "Amenities",
     "typeName" : "Amenities"
  }

`

But on the top (in the /index/detail/ response) I don't know where the tagids are came from. Are they inherited from ancestors or not? It is not determinable. I receive only a tagid array. I think we need a small work on the back-end. Please return only inherited tagids when they are come from ancestor nodes.

bkucsera commented 3 years ago

@scd Can you please check/confirm this?

scd commented 3 years ago

@bkucsera can I just confirm your requirements are for me not to return inherited tags but rather just tags directly associated with the node.

From the context of the discussion I think this is what you want but the last sentence stating your requirements is a little confusing as it implies you want inherited tags.

andrasbari commented 3 years ago

@killakalle please describe more. I don't understand where is the problem. We inherit only inheritable tags. Here is the JAVA code we use:

/**
 * https://www.thecrag.com/en/article/tagging see Inherits
 *
 * @return
 */
public RealmResults<Tag> getTagsWithInherited() {
    ArrayList<Long> ancestorTagIds = getAncestorTagIds();
    Realm realm = null;
    if (isManaged()) {
        realm = getRealm();
    } else {
        realm = TheCragDataManager.getRealm();
    }
    return realm.where(Tag.class)
            .in(Tag.DB_ID, tagIds.toArray(new Long[tagIds.size()]))
            .or()
            .beginGroup()
            .in(Tag.DB_ID, ancestorTagIds.toArray(new Long[ancestorTagIds.size()])).equalTo(Tag.DB_INHERITS, true)
            .endGroup()
            .sort(Tag.DB_ICON_URL, Sort.DESCENDING)
            .findAll();
}

/**
 * https://www.thecrag.com/en/article/tagging see Inherits
 *
 * @return
 */
public ArrayList<Long> getAncestorTagIds() {
    ArrayList<Long> tagIdList = new ArrayList<>();
    NodeDetail parentNodeDetail = getParentNode();
    if (parentNodeDetail != null) {
        tagIdList.addAll(parentNodeDetail.getAncestorTagIds());
    }
    tagIdList = (ArrayList<Long>) tagIdList.stream().distinct().collect(Collectors.toList());
    return tagIdList;
}

We list the tags for the received tagids of the selected node. Additionally we query for ancestor tags which are inheritable. @scd was it correct?

killakalle commented 3 years ago

@andrasbari my bad. The area I mentioned in the original post actually had only non-inheritable tags.

Though, I checked for another area now, and there inheritable tags are not inherited either.

On "Ruinas" the tag "Caliza" (Limestone) is missing. image

https://www.thecrag.com/es/escalar/spain/valencia/gestalgar/area/2561079750 image

scd commented 3 years ago

The api for the index query returns tags directly associated with the node, so if you want inherited tags you have to look at ancestors. I think the api is correct, but if you think not then please let me know.

andrasbari commented 3 years ago

I think the api is correct. I found a commented line in Android code. I fixed inheritance.

rouletout commented 3 years ago

@killakalle can you please confirm that it behaves correctly from your point of view?

killakalle commented 3 years ago

Looks good