# Use this for calculating running stats my $all_current_plays = $game->plays->search({ GameIdentifier => $play->GameIdentifier, id => { '<=', $play->id } })->search(undef, { cache => 1 } ); my $all_current_home_plays = $all_current_plays->search({ b_home_possession => 1 })->search(undef, { cache => 1 }); my $all_current_away_plays = $all_current_plays->search({ b_home_possession => 0 })->search(undef, { cache => 1 }); #### if(my $b = $all_current_home_plays->search({ b_pass => 1 })) { my $count = $b->count; if($count >0) { #CALCULATIONS NEEDING A PASS PLAY TO HAVE OCCURRED my $completes = $count - $b->search({ b_incomplete => 1 })->count; my $sum = $b->get_column('yards')->sum; my $ints = $b->search({ b_intercepted => 1 })->count; if(my $c = $b->search({ down => 1 })) { my $acount = $c->count; if($acount > 0) { $stats{HTO_1st_YPP} = $b->search({ down => 1 })->get_column('yards')->sum / $acount; my $totals; while(my $d = $c->next) { $totals += $d->_get_pass_score; } $stats{HTO_1st_Pass_Score_Avg} = $totals / $acount; } }