App-Repository

 view release on metacpan or  search on metacpan

lib/App/Repository.pm  view on Meta::CPAN

# summarize_rows()
#############################################################################

=head2 summarize_rows()

    * Signature: $summarized_rows = $rep->summarize_rows($table, $rows, $columns, $summary_keys, $options);
    * Param:     $table            string
    * Param:     $rows             [][]
    * Param:     $columns          []
    * Param:     $summary_keys       []
    * Param:     $formulas         {}
    * Return:    $summarized_rows  []
    * Throws:    App::Exception::Repository
    * Since:     0.01

    Sample Usage: 

    @rows = (
        [ 5, "Jim", "Green", 13.5, 320, ],
        [ 3, "Bob", "Green",  4.2, 230, ],
        [ 9, "Ken", "Green", 27.4, 170, ],
        [ 2, "Kim", "Blue",  11.7, 440, ],
        [ 7, "Jan", "Blue",  55.1,  90, ],
        [ 1, "Ben", "Blue",  22.6, 195, ],
    );
    @columns = ( "id", "name", "team", "rating", "score" );
    @summary_keys = ( "team" );

    $summarized_rows = $rep->summarize_rows(\@rows, \@columns, \@summary_keys, \%formulas);

    @rows = (
        { id=>5, name=>"Jim", team=>"Green", rating=>13.5, score=>320, },
        { id=>3, name=>"Bob", team=>"Green", rating=> 4.2, score=>230, },
        { id=>9, name=>"Ken", team=>"Green", rating=>27.4, score=>170, },
        { id=>2, name=>"Kim", team=>"Blue",  rating=>11.7, score=>440, },
        { id=>7, name=>"Jan", team=>"Blue",  rating=>55.1, score=> 90, },
        { id=>1, name=>"Ben", team=>"Blue",  rating=>22.6, score=>195, },
    );
    @columns = ( "rating", "score" );  # summarize a subset of the columns



( run in 0.364 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )