Forum Discussion

dustin's avatar
dustin
Expert
10 years ago

How do I display the kudos for a specific message in a custom component using freemarker?

 

The following code will select the kudo information for a specific message, but I can't figure out how to display the weighted sum of the kudos using freemarker.  Any ideas?  

 

<#assign kudos = rest("2.0","/search?q=" + "SELECT * FROM kudos WHERE message.id = '100'"?url).data.items />

 

 

  • Hi dustin

     

    have you tried retrieving the weighted sum directly

     

    SELECT kudos.sum(weight) FROM messages WHERE message.id = '100' 

    So the freemarker would be

    <#assign response = rest("2.0","/search?q=" + "SELECT kudos.sum(weight) FROM messages WHERE id = '100'"?url).data.items />
    ${response[0].kudos.sum.weight}

    Hope it helps

2 Replies

  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    10 years ago

    Hi dustin

     

    have you tried retrieving the weighted sum directly

     

    SELECT kudos.sum(weight) FROM messages WHERE message.id = '100' 

    So the freemarker would be

    <#assign response = rest("2.0","/search?q=" + "SELECT kudos.sum(weight) FROM messages WHERE id = '100'"?url).data.items />
    ${response[0].kudos.sum.weight}

    Hope it helps

  • dustin's avatar
    dustin
    Expert
    10 years ago
    Thanks. Message kudos were not being returned with the SELECT * query for message data. Only the kudos query is returned. Making this request as a separate query worked.

    Thanks!