Skip to content

Commit

Permalink
Removes ++ "This is why you can't have nice things"
Browse files Browse the repository at this point in the history
  • Loading branch information
oalders committed Dec 30, 2011
1 parent b1469b3 commit 05fed8f
Show file tree
Hide file tree
Showing 20 changed files with 8 additions and 345 deletions.
26 changes: 0 additions & 26 deletions lib/MetaCPAN/Web/Controller/Account/Favorite.pm

This file was deleted.

33 changes: 0 additions & 33 deletions lib/MetaCPAN/Web/Controller/Favorite.pm

This file was deleted.

1 change: 0 additions & 1 deletion lib/MetaCPAN/Web/Controller/Module.pm
Expand Up @@ -35,7 +35,6 @@ sub index : PathPart('module') : Chained('/') : Args {
);
$reqs = $self->recv_all($reqs);
$self->stash_api_results($c, $reqs, $data);
$self->add_favorites_data($data, $reqs->{favorites}, $data);

my $hr = HTML::Restrict->new;
$hr->set_rules(
Expand Down
6 changes: 0 additions & 6 deletions lib/MetaCPAN/Web/Controller/Recent.pm
Expand Up @@ -16,10 +16,4 @@ sub index : Path {
);
}

sub faves : Path('/recent/favorites') {
my ( $self, $c ) = @_;
$c->res->redirect( '/favorite/recent', 301 );
$c->detach;
}

1;
1 change: 0 additions & 1 deletion lib/MetaCPAN/Web/Controller/Release.pm
Expand Up @@ -38,7 +38,6 @@ sub index : PathPart('release') : Chained('/') : Args {
);
$reqs = $self->recv_all($reqs);
$self->stash_api_results($c, $reqs, $out);
$self->add_favorites_data($out, $reqs->{favorites}, $out);

# shortcuts
my ($root, $modules) = @{$reqs}{qw(root modules)};
Expand Down
92 changes: 0 additions & 92 deletions lib/MetaCPAN/Web/Model/API/Favorite.pm

This file was deleted.

18 changes: 6 additions & 12 deletions lib/MetaCPAN/Web/Model/API/Module.pm
Expand Up @@ -120,9 +120,8 @@ sub search_distribution {
my @ids = map { $_->{fields}->{id} } @{ $data->{hits}->{hits} };
my $descriptions = $self->search_descriptions(@ids);
my $ratings = $self->model('Rating')->get(@distributions);
my $favorites = $self->model('Favorite')->get( $user, @distributions );
$_ = $_->recv for ( $ratings, $favorites, $descriptions );
my $results = $self->_extract_results( $data, $ratings, $favorites );
$_ = $_->recv for ( $ratings, $descriptions );
my $results = $self->_extract_results( $data, $ratings, );

map { $_->{description} = $descriptions->{results}->{ $_->{id} } }
@{$results};
Expand Down Expand Up @@ -160,15 +159,14 @@ sub search_collapsed {

@distributions = splice( @distributions, $from, 20 );
my $ratings = $self->model('Rating')->get(@distributions);
my $favorites = $self->model('Favorite')->get( $user, @distributions );
my $results = $self->model('Module')
->search( $query, $self->_search_in_distributions(@distributions) );
$_ = $_->recv for ( $ratings, $favorites, $results );
$_ = $_->recv for ( $ratings, $results );

$took += max( grep {defined} $ratings->{took},
$results->{took}, $favorites->{took} )
$results->{took} )
|| 0;
$results = $self->_extract_results( $results, $ratings, $favorites );
$results = $self->_extract_results( $results, $ratings );
$results = $self->_collapse_results($results);
my @ids = map { $_->[0]->{id} } @$results;
$data = {
Expand Down Expand Up @@ -226,7 +224,7 @@ sub search_descriptions {
}

sub _extract_results {
my ( $self, $results, $ratings, $favorites ) = @_;
my ( $self, $results, $ratings ) = @_;
return [
map {
{
Expand All @@ -235,10 +233,6 @@ sub _extract_results {
score => $_->{_score},
rating =>
$ratings->{ratings}->{ $_->{fields}->{distribution} },
favorites =>
$favorites->{favorites}->{ $_->{fields}->{distribution} },
myfavorite => $favorites->{myfavorites}
->{ $_->{fields}->{distribution} },
}
} @{ $results->{hits}->{hits} }
];
Expand Down
5 changes: 0 additions & 5 deletions lib/MetaCPAN/Web/Model/API/Release.pm
Expand Up @@ -211,11 +211,6 @@ sub versions {
);
}

sub favorites {
my ( $self, $dist ) = @_;
$self->request( '/favorite/_search', {} );
}

__PACKAGE__->meta->make_immutable;

1;
11 changes: 0 additions & 11 deletions lib/MetaCPAN/Web/Model/API/User.pm
Expand Up @@ -26,15 +26,4 @@ sub get_profile {
$self->request( "/user/profile", undef, { token => $token } );
}

sub add_favorite {
my ( $self, $data, $token ) = @_;
$self->request( "/user/favorite", $data, { token => $token } );
}

sub remove_favorite {
my ( $self, $data, $token ) = @_;
$self->request( "/user/favorite/" . $data->{distribution},
undef, { method => 'DELETE', token => $token } );
}

1;
12 changes: 0 additions & 12 deletions lib/MetaCPAN/Web/Role/ReleaseInfo.pm
Expand Up @@ -6,17 +6,8 @@ use Moose::Role;

# TODO: should some of this be in a separate (instantiable) model
# so you don't have to keep passing $data?
# then wouldn't have to pass favorites back in.
# Role/API/Aggregator?, Model/APIAggregator/ReleaseInfo?

# add favorites and myfavorite data into $main hash
sub add_favorites_data {
my ( $self, $main, $favorites, $data ) = @_;
$main->{myfavorite} = $favorites->{myfavorites}->{ $data->{distribution} };
$main->{favorites} = $favorites->{favorites}->{ $data->{distribution} };
return;
}

# TODO: should the api_requests be in the base controller role,
# and then the default extras be defined in other roles?

Expand All @@ -27,9 +18,6 @@ sub api_requests {
return {
author => $c->model('API::Author')->get( $data->{author} ),

favorites => $c->model('API::Favorite')
->get( $c->user_exists ? $c->user->id : undef, $data->{distribution} ),

rating => $c->model('API::Rating')->get( $data->{distribution} ),

versions => $c->model('API::Release')->versions( $data->{distribution} ),
Expand Down
26 changes: 0 additions & 26 deletions root/favorite/leaderboard.html

This file was deleted.

27 changes: 0 additions & 27 deletions root/favorite/recent.html

This file was deleted.

20 changes: 0 additions & 20 deletions root/inc/favorite-table.html

This file was deleted.

11 changes: 0 additions & 11 deletions root/inc/favorite.html

This file was deleted.

1 change: 0 additions & 1 deletion root/module.html
Expand Up @@ -6,7 +6,6 @@
 / 
<% module.documentation %>
</big></strong>
<% INCLUDE inc/favorite.html module = module %>
<% IF release.status != 'latest' %><div style="float: right"><strong><big><% IF release.maturity == 'developer'; 'dev release, '; END %></big><a href="/module/<% module.documentation %>"><big>go to latest</big></a></strong></div><% END %><br><br>

<div class="search-bar">
Expand Down
1 change: 0 additions & 1 deletion root/recent.html
@@ -1,7 +1,6 @@
<%- rss = 'recent?f=' _ c.req.params.f || 'l' %>
<div class="search-bar">
<% INCLUDE inc/activity.html query = 'f=' _ c.req.params.f || 'l' %>
<a href ="/favorite/recent">Recent ++</a>
<hr/>
<strong>Filter</strong>
<form action="<% c.uri_for('/recent') %>" method="get" onchange="this.form.submit()">
Expand Down
1 change: 0 additions & 1 deletion root/release.html
@@ -1,6 +1,5 @@
<% title = release.name _ ' - ' _ release.abstract; rss = 'distribution/' _ release.distribution %>
<strong><big><a rel="author" href="/author/<% release.author %>" title="<% author.asciiname %>"><% author.name %></a> &nbsp;/&nbsp; <% release.name %></big></strong>
<% INCLUDE inc/favorite.html module = release %>
<% IF release.status != 'latest' %><div style="float: right"><strong><big><% IF release.maturity == 'developer'; 'dev release, '; END %></big><a href="/release/<% release.distribution %>"><big>go to latest</big></a></strong></div><% END %><br><br>

<div class="search-bar">
Expand Down

0 comments on commit 05fed8f

Please sign in to comment.