getTeamsByInfo order team list by amountRaised

Options
I'm using the getTeamsByInfo to display a list of all teams associated with a specific teamraiser on a leaderboard page where we want the teams ordered by amountRaised.


Side note: We chose to use the API rather than the S36 tag because the S36 tag maxes out at 95 teams, where we have more than hundred teams that need to be displayed.


Has anyone discovered a way to order the teams by amountRaised using getTeamsByInfo?


http://open.convio.com/api/#teamraiser_api.getTeamsByInfo_method.html


Thanks in advance!
Tagged:

Comments

  • Hi Kate,


    just curious whether you have tried the "list_sort_column" and "list_ascending" parameter API call could include?


    If not, from quick recollection in past at moment, I have also been using underscore.js library -- http://underscorejs.org/ to do some sort functionality on returned LO API call whenever default parameters aren't available / or if I need to do secondary/nested sorting.


    regards,

    Daniel

    EDIT ADD ON:

    found it..

    http://stepout.diabetes.org/site/TR?fr_id=11316&pg=entry

    Here's I think one example where I use that .sortBy functionality from the underscore.js library to sort the Team listing by their amount raised.


    partial snippet (from the point where the API call result is being returned as JSON object)


    var teamsListing = luminateExtend.utils.ensureArray(data.getTeamSearchByInfoResponse.team);

    var teamsListingSortedRaised = _.sortBy(teamsListing,function(teamsListing){

    return Number(teamsListing.amountRaised);

    }).reverse();



    add on note:
    • I am using Noah's Luminate Extend library to do the Convio API call (hence the luminateExtend reference within the snippet) also in my actual example, I don't need to include the cent decimals,so you could slice that portion out with javascript.
    • this is not an actual event teamraiser rather my development sandbox, hence those API call is actually calling a different FRID (of actual event so that I could use the same live data for this sorting/listing purpose) then the development teamraiser FRID just in case if that inadvertently creates confusion. Also on this prototyping sandbox I don't really get to use pagination to show more team post first 1000 (and there's not even 1000 teams from that actual live FRID, thus)
    hope this helps further.



    Kate Gollogly:

    I'm using the getTeamsByInfo to display a list of all teams associated with a specific teamraiser on a leaderboard page where we want the teams ordered by amountRaised.


    Side note: We chose to use the API rather than the S36 tag because the S36 tag maxes out at 95 teams, where we have more than hundred teams that need to be displayed.


    Has anyone discovered a way to order the teams by amountRaised using getTeamsByInfo?


    http://open.convio.com/api/#teamraiser_api.getTeamsByInfo_method.html


    Thanks in advance!

  • Kate Gollogly:

    I'm using the getTeamsByInfo to display a list of all teams associated with a specific teamraiser on a leaderboard page where we want the teams ordered by amountRaised.


    Side note: We chose to use the API rather than the S36 tag because the S36 tag maxes out at 95 teams, where we have more than hundred teams that need to be displayed.


    Has anyone discovered a way to order the teams by amountRaised using getTeamsByInfo?


    http://open.convio.com/api/#teamraiser_api.getTeamsByInfo_method.html


    Thanks in advance!

    To sort by amount raised, you'll use list_sort_column=total. The same is true for like methods, such as getParticipants and getCompaniesByInfo.
  • Thank you Daniel and Noah!


    We stuck with getTeamsByInfo and were able to order by amountRaised using list_sort_column=total.


    We decided to go with the API option over the s-tag option because we wanted to list all teams, whereas the s-tag caps of the top teams list at 100 teams.


    The tricky part was trying to re-format the amountRaised.


    Example:


    Changing $1840000 to $18,400.00


    We did using the following code:


    function formatCurrency(){

    $(".team-raised").each(function(){

    var str = parseInt($(this).text());

    if(str > 0){

    str = str.toString();

    str = str.substring(0,str.length-2) + "." + str.substring(str.length-2);

    str = str.replace(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/g, "$1,");

    $(this).text(str);

    }

    });

    }


    Here is a link to where we were testing: http://give.camh.ca/site/PageNavigator/OneBraveNight/obn2017/content/obn2017_teamPage.html


  • Thanks for the information on using 'total' for sorting by amountRaised.


    It seems like other columns like divisionName and captainLastName don't work with sorting, could they also have a different column name for sorting? And would you know where we could find that out?
  • To sort by division, use list_sort_column=division_name, for captain last name, use list_sort_column=c.last_name.
  • Thanks, that worked.

Categories