use Newslash::Util::Formatters;
use Newslash::Util::Items;
+use constant CACHE_SEC => 30;
+
sub _make_navitem {
my ($self, $item) = @_;
return if !$item;
my $show_future = $user->{is_admin} ? 1 : 0;
my $show_nonpublic = $user->{is_admin} ? 1 : 0;
- my $items = $c->model('stories')->select(show_future => $show_future,
- show_nonpublic => $show_nonpublic,
- limit => $limit + 1,
- order_by => {create_time => 'desc'},
- );
+ # my $items = $c->model('stories')->select(show_future => $show_future,
+ # show_nonpublic => $show_nonpublic,
+ # limit => $limit + 1,
+ # order_by => {create_time => 'desc'},
+ # );
+ my $items = $c->model_cache->select("stories", CACHE_SEC,
+ show_future => $show_future,
+ show_nonpublic => $show_nonpublic,
+ limit => $limit + 1,
+ order_by => {create_time => 'desc'},
+ );
$c->_render_timeline(items => $items,
limit => $limit);
sub recent {
my $c = shift;
my $limit = $c->_get_config("item_per_page", 10);
- my $items = $c->model('timeline')->select(limit => $limit);
+ #my $items = $c->model('timeline')->select(limit => $limit);
+ my $items = $c->model_cache->select('timeline', CACHE_SEC,
+ limit => $limit);
$c->_render_timeline(items => $items,
limit => $limit,
$popular_period = {days => 3};
}
- my $items = $c->model('timeline')->select(limit => $limit,
- order_by => {popularity => "DESC"},
- %$popular_period);
+ #my $items = $c->model('timeline')->select(limit => $limit,
+ # order_by => {popularity => "DESC"},
+ # %$popular_period);
+ my $items = $c->model_cache->select('timeline', CACHE_SEC,
+ limit => $limit,
+ order_by => {popularity => "DESC"},
+ %$popular_period);
+
$c->_render_timeline(items => $items,
limit => $limit,
title => "人気");
sub comments {
my $c = shift;
my $limit = $c->_get_config("item_per_page", 10);
- my $items = $c->model('comments')->select(limit => $limit + 1,
- order_by => {create_time => 'DESC'});
+ #my $items = $c->model('comments')->select(limit => $limit + 1,
+ # order_by => {create_time => 'DESC'});
+ my $items = $c->model_cache->select('comments', CACHE_SEC,
+ limit => $limit + 1,
+ order_by => {create_time => 'DESC'});
$c->_render_timeline(items => $items,
limit => $limit,
sub journals {
my $c = shift;
my $limit = $c->_get_config("item_per_page", 10);
- my $items = $c->model('journals')->select(limit => $limit + 1,
- order_by => {create_time => 'DESC'});
+ #my $items = $c->model('journals')->select(limit => $limit + 1,
+ # order_by => {create_time => 'DESC'});
+ my $items = $c->model_cache->select('journals', CACHE_SEC,
+ limit => $limit + 1,
+ order_by => {create_time => 'DESC'});
$c->_render_timeline(items => $items,
limit => $limit,
sub submissions {
my $c = shift;
my $limit = $c->_get_config("item_per_page", 10);
- my $items = $c->model('submissions')->select(limit => $limit + 1,
- order_by => {create_time => 'DESC'});
+ #my $items = $c->model('submissions')->select(limit => $limit + 1,
+ # order_by => {create_time => 'DESC'});
+ my $items = $c->model_cache->select('submissions', CACHE_SEC,
+ limit => $limit + 1,
+ order_by => {create_time => 'DESC'});
$c->_render_timeline(items => $items,
limit => $limit,
sub polls {
my $c = shift;
my $limit = $c->_get_config("item_per_page", 10);
- my $items = $c->model('polls')->select(limit => $limit + 1,
- order_by => {create_time => 'DESC'});
+ #my $items = $c->model('polls')->select(limit => $limit + 1,
+ # order_by => {create_time => 'DESC'});
+ my $items = $c->model_cache->select('polls', CACHE_SEC,
+ limit => $limit + 1,
+ order_by => {create_time => 'DESC'});
$c->_render_timeline(items => $items,
limit => $limit,