Counting Sheep.. well actually Counting Students by School.
Overview
In my naive state, I was puzzling over how to get at $resultset->count through the Façade. This little pile of doo-doo talks about it.
Countin in the ResulSet
This is done with the ->count method which exists for any DBIC ResulSet.
In Result::Assessment::Administration I defined:
sub count_students_by_school { my($self, $school_id) = @_; return $self->students2classes({ 'me.school_id' => $school_id }) ->related_resultset('student')->count; }
Access From the Façade
In Facade::Assessment::Adminstration I put:
sub count_students_by_school { my $self = shift; return $self->_assessment_administration_store->count_students_by_school(@_); }
Using the Count
Then to test the count was actually there I accessed the Facade method from an Assessment::Administration instance in the school_students action of the controller: Controller::Assessment::Administration like so:
warn "COUNT STUDENTS BY SCHOOL: " . $admin->count_students_by_school( $school->id );
Showing changes from previous revision. Removed | Added
