Skip to content

Commit

Permalink
Logic for stargazers display for $user.
Browse files Browse the repository at this point in the history
  • Loading branch information
Talina06 committed Jul 8, 2014
1 parent 4455ced commit 60b1626
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
22 changes: 7 additions & 15 deletions cpanfile.snapshot
Expand Up @@ -2792,16 +2792,17 @@ DISTRIBUTIONS
inc::MakeMaker undef
requirements:
ExtUtils::MakeMaker 6.30
JSON-MaybeXS-1.001000
pathname: M/MS/MSTROUT/JSON-MaybeXS-1.001000.tar.gz
JSON-MaybeXS-1.002002
pathname: E/ET/ETHER/JSON-MaybeXS-1.002002.tar.gz
provides:
JSON::MaybeXS 1.001000
JSON::MaybeXS 1.002002
requirements:
Cpanel::JSON::XS 2.3310
ExtUtils::CBuilder 0.27
ExtUtils::MakeMaker 0
File::Spec 0
File::Temp 0
JSON::PP 2.27202
Test::More 0.88
Test::Without::Module 0.17
perl 5.006
JSON-PP-2.27203
pathname: M/MA/MAKAMAKA/JSON-PP-2.27203.tar.gz
provides:
Expand Down Expand Up @@ -5033,15 +5034,6 @@ DISTRIBUTIONS
Exporter 5.57
ExtUtils::MakeMaker 0
Scalar::Util 0
Scalar-List-Utils-1.38
pathname: P/PE/PEVANS/Scalar-List-Utils-1.38.tar.gz
provides:
List::Util 1.38
List::Util::XS 1.38
Scalar::Util 1.38
requirements:
ExtUtils::MakeMaker 0
Test::More 0
Starman-0.4009
pathname: M/MI/MIYAGAWA/Starman-0.4009.tar.gz
provides:
Expand Down
27 changes: 27 additions & 0 deletions lib/MetaCPAN/Web/Controller/Account.pm
Expand Up @@ -26,6 +26,33 @@ sub settings : Local {
my ( $self, $c ) = @_;
}

sub index : Chained('/') PathPart('account') CaptureArgs(0) {
}

sub stargazer_display : Chained('index') PathPart('stargazer') Args(0) {
my ( $self, $c ) = @_;
my $user = $c->model('API::User')->get_profile( $c->token )->recv;
my $stars_cv = $c->model('API::Stargazer')->by_user( $user->{user} );
my $starred_data = $stars_cv->recv;

my @starred_modules = map {
{
module => $_->{fields}->{module},
author => $_->{fields}->{author},
date => $_->{fields}->{date}
}
} @{ $starred_data->{hits}->{hits} };

my $total_starred = @starred_modules;
$c->stash(
{
starred_modules => \@starred_modules,
template => 'account/stargazer.html'
}
);

}

sub identities : Local {
my ( $self, $c ) = @_;
if ( $c->req->method eq 'POST'
Expand Down
16 changes: 0 additions & 16 deletions lib/MetaCPAN/Web/Controller/Account/Stargazer.pm
Expand Up @@ -29,20 +29,4 @@ sub add : Local {
}
}

sub list : Local {
my ( $self, $c ) = @_;

my $user = $c->model('API::User')->get_profile( $c->token )->recv;

my $stars_cv = $c->model('API::Stargazer')->by_user( $user->{user} );
my $stars_data = $stars_cv->recv;
my $stars = [
sort { $b->{date} cmp $a->{date} }
map { $_->{fields} } @{ $stars_data->{hits}{hits} }
];

$c->stash( { stars => $stars } );

}

__PACKAGE__->meta->make_immutable;

0 comments on commit 60b1626

Please sign in to comment.