Forum Discussion

vishwajeet_hol's avatar
10 years ago

Get list of users having specific role(sorted by their post count) using REST v2 call.

Hi All,

 

I need the list of users having specific role. And this users should be sorted by their post count in descending order.

REST v2 call will be preferred.

 

Let me know, if you have any idea to achieve this.

 

Thanks in advance!!!

 

Regards,

Vishwajeet

  • OlivierS's avatar
    OlivierS
    Lithium Alumni (Retired)

    vishwajeet_hol here is the API v2 call (but it doesn't sort by post count):

     

    SELECT id, login FROM users WHERE roles.name='Administrator'
    SELECT * FROM users WHERE roles.name IN ('Administrator', 'Community Manager')

     And here is the user resource documentation.

      • VarunGrazitti's avatar
        VarunGrazitti
        Boss

        vishwajit_shind  You can count the entire Message collection or filter the message count based on any field supported in the WHERE clause. The count(*) field can only be returned; it is not supported in a WHERE or ORDER BY clause. ORDER BY, LIMIT, and OFFSET have no effect on count(*).

         

        For example,

         

        SELECT count(*) FROM messages LIMIT 10 will ignore the limit. In addition, count(*) cannot be used in a partial response.

         

        For example,

         

        SELECT count(*), id, subject FROM messages WHERE author.login = 'SusanH' is not supported.

         

        The message count returned will be exact when the query is scoped to board.id in the WHERE clause.

         

        Queries scoped to other fields, queries that filter by multiple fields (including board.id), and unscoped queries will return a close estimation to the actual count. Examples of queries that will return estimated counts include:

         

        SELECT count(*) FROM messages SELECT count(*) FROM messages WHERE author.login = 'SusanH' SELECT count(*) FROM messages WHERE board.id = 'developerForum' AND author.name = 'SusanH'

         

        Source: http://community.lithium.com/t5/Community-API-v2/Message-resource/ta-p/113091