5 |
|
|
6 |
use Jifty::View::Declare -base; |
use Jifty::View::Declare -base; |
7 |
use A3C::LDAP; |
use A3C::LDAP; |
8 |
|
use A3C::SQL; |
9 |
|
|
10 |
use Data::Dump qw/dump/; |
use Data::Dump qw/dump/; |
11 |
|
|
25 |
dt { _('Number of persons in system') } |
dt { _('Number of persons in system') } |
26 |
dd { $people->count } |
dd { $people->count } |
27 |
|
|
28 |
=for later |
my $by_towns = A3C::SQL->new({ query => qq{ |
29 |
|
select count(uid),l |
30 |
|
from organizations |
31 |
|
inner join towns on towns.name = l |
32 |
|
group by l |
33 |
|
order by count desc |
34 |
|
limit 25 |
35 |
|
}}); |
36 |
|
|
37 |
dt { _('Breakdown by towns') } |
dt { _('Top %1 towns by schools', $by_towns->count) } |
38 |
dd { |
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; |
|
|
|
|
39 |
ul { |
ul { |
40 |
for ( 1 .. 1 ) { |
while ( my $row = $by_towns->next ) { |
41 |
my $o = $orgs->next; |
li { outs_raw( $row->count, ' ', $row->l ) } |
|
warn "## ",dump( $o ); |
|
|
li { outs ( $o->l, '|', $o->__value('l'), $o->__value( $count ) ) } |
|
42 |
} |
} |
43 |
} |
} |
|
|
|
|
|
|
44 |
} |
} |
45 |
|
|
46 |
=cut |
my $by_county = A3C::SQL->new({ query => qq{ |
47 |
|
select |
48 |
|
count(uid) as schools, |
49 |
|
county, |
50 |
|
count(distinct municipality) as municipalities |
51 |
|
from organizations |
52 |
|
inner join towns on towns.name = l |
53 |
|
group by county |
54 |
|
order by schools desc |
55 |
|
}}); |
56 |
|
|
57 |
|
dt { _('Schools by counties') } |
58 |
|
dd { |
59 |
|
table { |
60 |
|
th { _('Schools') } |
61 |
|
th { _('County') } |
62 |
|
th { _('Municipalities') }; |
63 |
|
while ( my $row = $by_county->next ) { |
64 |
|
row { |
65 |
|
cell { $row->schools } |
66 |
|
cell { $row->county } |
67 |
|
cell { $row->municipalities } |
68 |
|
} |
69 |
|
} |
70 |
|
} |
71 |
|
} |
72 |
}; |
}; |
73 |
|
|
74 |
|
|