--- lib/A3C/View.pm 2008/04/10 23:16:56 72 +++ lib/A3C/View.pm 2008/05/20 09:47:59 122 @@ -5,6 +5,7 @@ use Jifty::View::Declare -base; use A3C::LDAP; +use A3C::SQL; use Data::Dump qw/dump/; @@ -12,46 +13,62 @@ h1 { _('Statistics') } - my $orgs = A3C::Model::OrganizationCollection->new; + my $orgs = A3C::Model::hrEduOrgCollection->new; $orgs->unlimit; dt { _('Number of schools in system') } dd { $orgs->count } - my $people = A3C::Model::PersonCollection->new; + my $people = A3C::Model::hrEduPersonCollection->new; $people->unlimit; dt { _('Number of persons in system') } dd { $people->count } -=for later + my $by_towns = A3C::SQL->new({ query => qq{ + select count(uid),l + from hr_edu_orgs + inner join towns on towns.name = l + group by l + order by count desc + limit 25 + }}); - dt { _('Breakdown by towns') } + dt { _('Top %1 towns by schools', $by_towns->count) } dd { - $orgs->redo_search; - # select count(l),l from organizations group by l order by count desc limit 25 - $orgs->group_by( column => 'l' ); - $orgs->order_by( column => 'l', order => 'desc' ); - - warn "## SQL: ", $orgs->build_select_query; - my $count = $orgs->column( column => 'l', function => 'count(l)' ); - warn "## count: $count\n"; -# $orgs->column( column => 'l' ); - warn "## SQL: ", $orgs->build_select_query; - ul { - for ( 1 .. 1 ) { - my $o = $orgs->next; - warn "## ",dump( $o ); - li { outs ( $o->l, '|', $o->__value('l'), $o->__value( $count ) ) } + while ( my $row = $by_towns->next ) { + li { outs_raw( $row->count, ' ', $row->l ) } } } - - } -=cut + my $by_county = A3C::SQL->new({ query => qq{ + select + count(uid) as schools, + county, + count(distinct municipality) as municipalities + from hr_edu_orgs + inner join towns on towns.name = l + group by county + order by schools desc + }}); + dt { _('Schools by counties') } + dd { + table { + th { _('Schools') } + th { _('County') } + th { _('Municipalities') }; + while ( my $row = $by_county->next ) { + row { + cell { $row->schools } + cell { $row->county } + cell { $row->municipalities } + } + } + } + } }; @@ -83,7 +100,7 @@ h1 { _('Find people') } my $action = new_action( - class => 'SearchPerson', + class => 'SearchhrEduPerson', moniker => 'search-users', sticky_on_success => 1, sticky_on_failure => 1, @@ -121,7 +138,7 @@ ); form { - render_action( $action => [ 'cn' ] ); + render_action( $action => [ 'org_uid' ] ); form_submit( label => _('Sync Organization') ); };