GrowthForecast-Aggregator-Declare
https://metacpan.org/release/GrowthForecast-Aggregator-Declare
use GrowthForecast::Aggregator::Declare;
my @queries = gf {
section member => sub {
# post to member/count
db(
name => 'count',
description => 'The number of members',
query => 'SELECT COUNT(*) FROM member',
);
};
section entry => sub {
# post to entry/count, entry/count_unique
db_multi(
names => ['count', 'count_unique'],
descriptions => ['Total count of posts', 'Posted bloggers'],
query => 'SELECT COUNT(*), COUNT(DISTINCT member_id) FROM entry',
);
};
};
for my $query (@queries) {
$query->run(
dbh => $dbh,
ua => $ua,
service => 'blog_service',
endpoint => 'http://exapmle.com/api/',
);
}
gf にデータなげるの、なんかかっこいいかんじで DSL でパパーンとやってくれるのがほしかったので書いた。
Published: 2013-02-28(Thu) 00:06