Forum Discussion

AmarDoekhie's avatar
7 years ago

How do I get the total amount of post in the Community?

Hi,

 

I'm trying to find out how I can retrieve the total amount of post  on the community.

 

I tried a lot of methods, but I get very different results.

 

1. /restapi/vc/metrics/name/posts

2. Admin -> Metrics -> Overall post

3. LSI Content -> All categories -> Community structure -> Posts (I can only get 6 months of data per run)

4. api/2.0/search?q=select"count(*)" from "messages"

 

Can someone tell me what the correct way is?

 

Thanks in advanced,

 

Amar 

 

 

7 Replies

  • Are you trying to get the topics count or messgaes (reply included) count?

  • AmarDoekhie's avatar
    AmarDoekhie
    Helper
    7 years ago

    I'm trying to get all post including messages (and replies). So the absolute total of posts on the community.

  • AmarDoekhie's avatar
    AmarDoekhie
    Helper
    7 years ago

    Thank you for the two API calls, but why can't i get this from the LSI? or am I looking at the wrong metrics?

  • softech's avatar
    softech
    Guide
    8 months ago

    VikasB wrote:

    AmarDoekhie

    Try these two API. You should get the approx. similar count. 

    https://community.lithium.com/api/2.0/search?q=select%20count(*)%20from%20messages

    https://community.lithium.com/restapi/vc/posts/count

    Also, I would suggest you contact with lithium support to know it in detail. Find the helpful link here 

    https://community.lithium.com/t5/Developer-Discussion/Support-for-Elastic-Search/m-p/436976#U436976

     


    hi

    this is an old one..   but why the 2 ways give a different number.. the difference is quite significant

    929438 posts vs 964034 posts

  • Only the Khoros gods know the answer to that, I can produce like 5 different post counts in various ways, it's quite amazing 😂, choose which one fits you the best... Which one is accurate, no clue... And "half-way" implemented new features like content archive make it even worse, it's just a theory, but I think API v1 does not have any awareness of archived content, so it might "count" all posts? But API v2 does implement content archive somewhat, and it won't return anything that you archived except you explicitly ask via a WHERE visibility_scope = 'archived' constraint, but then of course you don't get the normally visible posts, so you have to do 2 queries because visibility_scope does NOT support WHERE visibility_scope = IN('archived', 'public') constraint... but no worries, you also won't usually get back the same numbers for these two queries:

    SELECT count(*) FROM messages
    SELECT count(*) FROM messages WHERE visibility_scope = 'public'

    and even thinkering around with other visibility scopes like 'moderator' etc. and trying to get somehow to the same count, I was not successful, so please, if you find the "formula", let us know!

    There's of course also the metrics section you could try and get some more different numbers... it of course depends which metric you are querying, in your case I think relevant ones could be:

    - net_overall_posts
    - net_posts
    - deleted_posts
    - deleted_overall_posts
    - posts
    - overall_posts_excluding_spam
    - overall_posts

  • thanks luk 

    for me, only visibility_scope = 'public' works

    I got this error for all other scopes.  But that is not an access issue, right?

     

     

    {"status":"error","message":"An unexpected error occurred.","data":{"type":"error_data","code":301,"developer_message":"","more_info":""},"metadata":{}}