Forum Discussion

dhiraj_gophane's avatar
10 years ago

Posts count discrepancy for users on Recent Post Page

Hello All,

 

This is regarding posts count discrepancy for users on two different pages.

 

On one page we are fetching user's overall posts count by making rest API call to get metrics of users.

/users/id/${user_id}/metrics

 

Then post count is calculates by following logic:

<#assign posts_count = overall_posts?number - deleted_overall_posts?number />

 

When we visit same user's recentpostspage then it shows lesser posts (less count).

 

Is there any specific reason for this behavior?

 

Regards,

Dhiraj

  • Hi Dhiraj, 

     

     

    Metrics are permissions dependent, so if the user in question has created posts in an area of the community that is not public and you are not permitted to access then the recent posts page will not show those posts and they will not appear as part of that count.

     

    If you're performing the API call using RESTADMIN instead of just REST then the data returned will be different. The recent posts page uses the context of the user thats viewing the page to retrieve data whereas the RESTADMIN call will pull the data as an admin would see it.

     

    Try changing from RESTADMIN to REST when calling the API and let us know if you see it matching up (you won't need to do the calculation to remove deleted posts with the standard REST call as this is already factored in to the figure returned).