DataWarehouse
view release on metacpan or search on metacpan
db_password => $db_password,
dimensions => [ map { _fake_dimension($_) } @dimensions ],
fact_table => $fact_table,
);
my $output = $mt->render($template,%param);
print $output, $data;
sub _fake_dimension {
my $name = shift;
return {
name => $name,
attributes => [ 'foo', 'bar', 'baz' ],
natural_key => "$name\_id",
};
}
=head1 NAME
dw-nav - generate a web based Data Warehouse Navigator
=head1 SYNOPSIS
dw-nav [options]
=head1 OPTIONS
=over
=item --dsn
=item --db_user
=item --db_password
=item --fact
The name of the fact table.
=item --dimension
The name of one or more dimensions.
=back
=head2 EXAMPLE
dw-nav --dsn='dbi:SQLite:dbname=test.db' \
--fact='sales' \
--dimension='user' \
--dimension='product'
=head1 DESCRIPTION
dw-nav will create the base of a simple Data Warehouse Navigator.
=head2 AGGREGATE NAVIGATOR
One of the main features of the Data Warehouse Navigator is the
transparent Aggregate Navigator.
The Aggregate Navigator will intercept SQL queries and generate
aggregate tables, whenever is possible.
The use of aggregate tables can speed up Data Warehouse by 100s
or 1000s of times.
=head1 AUTHOR
Nelson Ferraz, C<< <nferraz at gmail.com> >>
=head1 ACKNOWLEDGEMENTS
=head1 LICENSE AND COPYRIGHT
Copyright 2010 Nelson Ferraz.
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
=cut
__END__
% my %param = @_;
#!/usr/bin/perl
use lib './lib';
use Mojolicious::Lite;
use DataWarehouse::Fact;
use Data::Dumper;
my $fact = DataWarehouse::Fact->new(
dsn => '<%= $param{dsn} %>',
name => '<%= $param{fact_table} %>',
dimension => [qw/<%= join(' ', map { $_->{name} } @{$param{dimensions}}) %>/],
);
# /
get '/' => sub {
my $self = shift;
$self->render(
template => 'index',
fact => $fact,
);
};
get '/report' => sub {
my $self = shift;
my @dim_attr = grep { $self->param($_) eq 'on' } $self->param();
my @where = ();
my $query = $fact->aggr_query(\@dim_attr,\@where);
( run in 2.282 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )