XF 2.1 Is it possible to add message/like ratio on postbit?

betforumu

Member
I need something like that. For example user has 100 messages and 200 likes. His ratio would be "2" and added on postbit.
For example:

Nickname
-Avatar-
Location: London
Message Count: X
Like Count: X
* Message/Like Ratio: 2 *
 
Solution
It can be done with a simple edit of the message_macros template.

Message/Like Ratio
HTML:
<xf:if is="$user.reaction_score">
    <dl class="pairs pairs--justified">
        <dt>Message/Like Ratio</dt>
        <dd>{{ number($user.message_count/$user.reaction_score, 2) }}</dd>
    </dl>
</xf:if>


Like/Message Ratio
HTML:
<xf:if is="$user.reaction_score">
    <dl class="pairs pairs--justified">
        <dt>Like/Message Ratio</dt>
        <dd>{{ number($user.reaction_score/$user.message_count, 2) }}</dd>
    </dl>
</xf:if>

Change the 2 to the number of decimal places as required.


1606099134780.png
It can be done with a simple edit of the message_macros template.

Message/Like Ratio
HTML:
<xf:if is="$user.reaction_score">
    <dl class="pairs pairs--justified">
        <dt>Message/Like Ratio</dt>
        <dd>{{ number($user.message_count/$user.reaction_score, 2) }}</dd>
    </dl>
</xf:if>


Like/Message Ratio
HTML:
<xf:if is="$user.reaction_score">
    <dl class="pairs pairs--justified">
        <dt>Like/Message Ratio</dt>
        <dd>{{ number($user.reaction_score/$user.message_count, 2) }}</dd>
    </dl>
</xf:if>

Change the 2 to the number of decimal places as required.


1606099134780.png
 
Solution
It can be done with a simple edit of the message_macros template.

HTML:
<xf:if is="$user.reaction_score">
    <dl class="pairs pairs--justified">
        <dt>Message/Like Ratio</dt>
        <dd>{{ $user.message_count/$user.reaction_score|number }}</dd>
    </dl>
</xf:if>
It does display, but for a user in a test environment with 43108 messages and a 10968 reaction score the ratio that it is spitting back to me is 4310.8 – I note this is just the post count with the decimal place moved one spot. I believe the value should be more like 0.2544. We're running v2.2.1 in the test environment.

Edit: I think it needs to be "$user.message_count|number" and perhaps the other way around?
 
Last edited:
Just adapt the calculation as you need - divide the reaction score by the post count: $user.reaction_score/$user.message_count|number
Noted.

One final thing, I seem to get the number to 14 decimal places, is there a way to limit that? Some ratios have beautiful nice round numbers, or they run to only 2 decimal places, while others...
 
Been thinking about this and it only starts to fulfil its real potential of usefulness as a meaningful metric after so many posts.

For example someone could make just one post of a very nice video, they could easily get half a dozen likes for that one post so have a huge Like/post ration that isn't really representative of how useful a member they are.

It only really makes sense once a user has a decent amount of posts, and only then if the reactions are in relation to what they have to say, rather than if they just post videos and memes.

So maybe I'm cooling off the usefulness of this for now.
 
Back
Top Bottom