Forum Discussion

nathan's avatar
nathan
Executive
12 years ago

ideas stats

We would like to create a widget that displays stats from an ideas board - specifically, how many ideas have been submitted, accepted, implemented etc.

 

I've had a look through the REST API documentation, and whilst I can find something that will give us the total number of ideas (and even the total number within a specifed date range), I can't find anything that will break it down by the status of the idea.

 

Can anyone tell us how we can do this?

5 Replies

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Hi nathan,

     

    It looks like this is possible, but you must first know the id of the statuses you're interested in. You can obtain this information via the REST API as well by chaining the message_statuses/available methods onto the board (Idea Exchange) you're interested in. For example, here's how you would get the statuses for the idea exchange here on the Lithosphere:

    http://lithosphere.lithium.com/restapi/vc/boards/id/Lithium_Ideas/message_statuses/available

     

    Looking at the response, I can see that the id for the "New Idea" status is "2". So then I can make a call like this to get the count of threads (ideas) that have the "New Idea" status:

    http://lithosphere.lithium.com/restapi/vc/boards/id/Lithium_Ideas/threads/for/message_statuses/id/2/recent/count

     

    I hope this helps!

  • dementad's avatar
    dementad
    Genius
    12 years ago

    As a RESTAPI newbie, I would like to understand how exactly I would know, from the online docs, that message_statuses/available exists. If I look under messages, it is not listed. It appears that I must explicitly search for "available" in order to find the option, and, of course, I do not know a priori that "available" exists.

     

    Confusedly...

  • nathan's avatar
    nathan
    Executive
    12 years ago

    Thanks Adam.

     

    dementad - I managed to get a list of the statuses for ideas by looking at the 'Idea Status' list (component) on the main Idea page. The links reveal the status 'keys'.

     

    For example, if the link to Implemented ideas is:

    http://community.giffgaff.com/t5/Submit-Great-giffgaff-Ideas/idb-p/ideas_01/status-key/Implemented_001

     

    Then the REST API URL to get the number of implemented ideas is:

    http://community.giffgaff.com/napa/restapi/vc/boards/id/ideas_01/posts/for/message_statuses/key/Implemented_001

  • AdamN's avatar
    AdamN
    Khoros Oracle
    12 years ago

    Thanks nathan for the additional tips!

     

    Regarding the question from dementad about figuring out that the method even exists, it can indeed be tricky sometimes to figure out how to chain all of the different methods to get exactly what you want. There are a couple different approaches that often work well. I'll usually try and find what I want to end up with and then work my way backwards to figure out the methods I need to chain. Or sometimes I'll just start with the Community object and keep chaining until I find what I need.

     

    In this case, I actually wound up starting somewhere in the middle. I knew that I wanted to figure out the statuses for a node. So I searched the REST API docs for "status" and found that there was a method on the Board class called "message_statuses". From the docs, I can see that this method returns a BoardMessageStatusContext object, so I would check out that class next. In the BoardMessageStatusContext class, I see that there is an "available" method that returns "the available message statuses in this board". So at this point I know that my call is going to end with "message_statuses/available". Then I just need to work my way backwards, knowing that i have to chain "message_statuses" to a Board object. I know that I can get a Board object via the "boards/id/<id>" method on the Community object. So putting it all together, my call would be:

    "/boards/id/<id>/message_statuses/available"

  • dementad's avatar
    dementad
    Genius
    12 years ago

    Thanks AdamN for the methodology. It seems a little unusual to me to get different results for a search depending on which section of the API I have highlighted when I search, but now that I see that's how it works, I will... adjust.