Counting list output
Really hoping somebody can help.
I'm pulling in the number of unread posts in a thread using the following:
SELECT user_context.read FROM messages
This gives me a nice list of booleans, I've used ?then(x,y) to convert the booleans into either 0 (read) or 1 (unread). Using a list I'm running through each message from the LiQL query and printing the result. So far I'm ending up with a series of 1's for unread messages and nothing for read messages.
What I'd like to do is add all of the outputs together so I can display something like '4 New' as opposed to '1 1 1 1 New'. I feel like I've trawled FreeMarker endlessly with no joy beyond converting the boolean to a number.
Here's what I'm working with:
<#list> <#assign var1 to get each user_context.read result /> <#assign var2 to convert these to a number /> ${var2} </#list>
I've tried storing the number in var each time and incrementing it, but I end up with '2' then every time, it doesn't add up the actual instances of 1, just adds its value to itself again. I'm sure I'm missing something really obvious, would really appreciate some input.
N.B. I know there's a read messages piece in API v1, I'm trying to stick with using v2 if possible as everything else I've built is using v2 so that's what I'm familiar with right now.