From 1a2ec5dfa1e604a0df7ef0dd60975b0ce1df1c81 Mon Sep 17 00:00:00 2001 From: Angel Ortega Date: Wed, 15 Aug 2007 09:49:27 +0200 Subject: [PATCH] New method 'stories_top_ten' to Source::FS. --- Gruta/Source/FS.pm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Gruta/Source/FS.pm b/Gruta/Source/FS.pm index ecee2ac..8749643 100644 --- a/Gruta/Source/FS.pm +++ b/Gruta/Source/FS.pm @@ -376,6 +376,26 @@ sub search_stories { return @r; } +sub stories_top_ten { + my $self = shift; + my $num = shift; + + my @r = (); + + foreach my $topic_id ($self->topics()) { + foreach my $id ($self->stories_by_date($topic_id, 'num' => 1000)) { + my $story = $self->story($topic_id, $id); + + push(@r, [ $story->get('hits'), [ $id, $topic_id ]]); + } + } + + @r = map { $_->[1] } sort { $a->[0] cmp $b->[0] } @r; + + return @r; +} + + sub session { return _one( @_, 'Gruta::Data::FS::Session' ); } sub purge_old_sessions { -- 2.11.4.GIT