Forum Discussion

gatomonstruo's avatar
4 years ago

Custom Component: Recent post by roles.name not working

Hi Community,

 

Currently we are using a custom component to show the latest posts from a specific group of users. 

In our platform we have 2 main categories that work as different communities. One is in Spanish and one in Portuguese. 

So, in order to show the posts for each category, we use a key text to differentiate each one. 

Saying that, this is what we are using:

 

<#assign rolestop=text.format("custom.query.top_users","") />

<#assign authorQuery="select id from users where roles.name IN (${rolestop})" />

<#assign authors=commonFunctionUtils.executeLiQLQuery(authorQuery) />
<#if authors?size gt 0>
<#assign authorListArray=[] />


<#list authors as author>
<#assign authorListArray=authorListArray + [author.id] />
</#list>
<#assign authorList=authorListArray?join("','") />
                                            <#assign messagesQuery="select id,subject,body,  post_time,view_href,author.login, author.id, board.id,board.title,board.view_href,post_time,post_time_friendly,user_context.read,conversation.solved, kudos.sum(weight), board.title, board.id,metrics,replies.count(*) from messages where category.id = '${coreNode.id}' and author.id IN ('${authorList}') order by post_time desc LIMIT 10" />
                                            <#assign parceirosPosts=commonFunctionUtils.executeLiQLQuery(messagesQuery) />
                                            <#if parceirosPosts?size gt 0>
                                                <#list parceirosPosts as parceiroPost>
                                                    <#assign authorPostQuery="select rank, view_href, login, id, avatar from users where id = '${parceiroPost.author.id}'" />
                                                    <#assign authorPost=commonFunctionUtils.executeLiQLQuery(authorPostQuery)[0] />


[...]

 

 

In the key text (for the version in SP) we are using exactly this one

 

custom.query.top_users = 'Artesando de Noxus','Escudero de Demacia','Inventor de Hextech','Trovador de Jonia','Soporte al jugador'

 

 

Now the problem: 

 

The component is only showing the posts from authors with 'Soporte al Jugador' role and ignoring all others. If I remove that role from the key-text, it shows all the others without problem. 

 

I really don't have a clue why this is happening. I would really appreciate your help. 

 

Thanks in advance! 

 

KR,

 

 

4 Replies

  • Wow, this is an interesting one.  Do you see the same results when viewing the component as an admin user versus an anonymous or non-admin user?  

    I ask because I wonder if it has to do with the visibility of one or more of the roles by normal/unauthenticated users.

    I'm curious if you will see anything different if you call the commonFunctionUtils.executeLiQLQuery function as an admin.  For eample:

    <#assign authors = commonFunctionUtils.executeLiQLQuery(authorQuery, false, true) />

     

    Just spitballin' here, so it may not pan out, but I figured I'd make the suggestion just in case.

    Good luck!

  • Does it also do that when changing the order of the items in custom.query.top_users?

  • Hey, Hoekstra_VFZ jeffshurtliff 

    Thanks so much for your comments. I haven't had enough time these past weeks to check the suggestion, but I'll try to do it ending this week or early next week. 

    I'll be back here with the solutions once is working properly 😄 

    Once again, thanks 😄 

  • Are you receiving exactly 25 items in return for the authors query by any chance? Because by default you will only receive 25 result items per page ended by a cursor to the next batch of 25. (A good way to try this out is using the "API Browser" in studio btw). Its possible that by pure coincidence the first 25 matches are from the 'Suporto al Jugador' role.

    One way to work around is by ending the LiQL query with "LIMIT 1000" to increase the page size.