Forum Discussion

Warren_Brill's avatar
7 years ago

Method to Count How Many Members Use a Given Avatar Image?

Is there a method to count how many users have at given image on their profiles as their avatar? Seems unlikely, but if anyone would know, it would be somebody here. ;-)

  • Warren_Brill

    There is no such matric. But a workaround can be used here using the API. 

    <#assign count = 0 />
    <#assign ProfileAvatar = "/avatar-theme/candy/avatar-collection/music" />
    <#assign usersCount = rest( "2.0", "/search?q=" + "SELECT count(*) FROM users"?url).data.count />
    <#assign usersAvatar = rest( "2.0", "/search?q=" + "SELECT avatar.profile FROM users limit ${usersCount}"?url).data.items />

    <#list usersAvatar as userAvatar >
    <#assign avatar = userAvatar.avatar.profile />
    <#if avatar?contains(ProfileAvatar)>
    <#assign count= count+1 >
    </#if>
    </#list>
    Number of users having Candy theme as their profile = ${count}

    API can fetch the 1K records at once(default 1K) so if in your case if community users are more than 1K, you can increase this API limit by raising a ticket to support. 

  • Warren_Brill

    There is no such matric. But a workaround can be used here using the API. 

    <#assign count = 0 />
    <#assign ProfileAvatar = "/avatar-theme/candy/avatar-collection/music" />
    <#assign usersCount = rest( "2.0", "/search?q=" + "SELECT count(*) FROM users"?url).data.count />
    <#assign usersAvatar = rest( "2.0", "/search?q=" + "SELECT avatar.profile FROM users limit ${usersCount}"?url).data.items />

    <#list usersAvatar as userAvatar >
    <#assign avatar = userAvatar.avatar.profile />
    <#if avatar?contains(ProfileAvatar)>
    <#assign count= count+1 >
    </#if>
    </#list>
    Number of users having Candy theme as their profile = ${count}

    API can fetch the 1K records at once(default 1K) so if in your case if community users are more than 1K, you can increase this API limit by raising a ticket to support. 

    • Thanks - marking Accepted Solution because I think I can run with this.