Skip to content

Commit

Permalink
Merge pull request #1595 from LiquidPL/fix-785
Browse files Browse the repository at this point in the history
Add pending and graveyarded beatmapsets to profile page
  • Loading branch information
peppy committed Nov 14, 2017
2 parents b6cc123 + 38d20f6 commit 3acd106
Show file tree
Hide file tree
Showing 16 changed files with 170 additions and 103 deletions.
36 changes: 36 additions & 0 deletions app/Http/Controllers/UsersController.php
Expand Up @@ -165,6 +165,14 @@ public function beatmapsets($id, $type)
case 'ranked_and_approved':
return $this->rankedAndApprovedBeatmapsets($this->user, $this->perPage, $this->offset);

case 'unranked':
return $this->unrankedBeatmapsets($this->user, $this->perPage, $this->offset);

case 'graveyard':
$this->parsePaginationParams(2);

return $this->graveyardBeatmapsets($this->user, $this->perPage, $this->offset);

default:
abort(404);
}
Expand Down Expand Up @@ -209,6 +217,8 @@ public function show($id, $mode = null)
'page',
'recentActivities',
'rankedAndApprovedBeatmapsetCount',
'unrankedBeatmapsetCount',
'graveyardBeatmapsetCount',
'favouriteBeatmapsetCount',
]
);
Expand Down Expand Up @@ -244,6 +254,8 @@ public function show($id, $mode = null)
'most_played' => $this->mostPlayedBeatmapsets($user),
'ranked_and_approved' => $this->rankedAndApprovedBeatmapsets($user),
'favourite' => $this->favouriteBeatmapsets($user),
'unranked' => $this->unrankedBeatmapsets($user),
'graveyard' => $this->graveyardBeatmapsets($user),
];

$kudosu = $this->recentKudosu($user);
Expand Down Expand Up @@ -362,6 +374,30 @@ private function favouriteBeatmapsets($user, $perPage = 6, $offset = 0)
);
}

private function unrankedBeatmapsets($user, $perPage = 6, $offset = 0)
{
return json_collection(
$user->profileBeatmapsetsUnranked()
->limit($perPage)
->offset($offset)
->get(),
'BeatmapsetCompact',
['beatmaps']
);
}

private function graveyardBeatmapsets($user, $perPage = 2, $offset = 0)
{
return json_collection(
$user->profileBeatmapsetsGraveyard()
->limit($perPage)
->offset($offset)
->get(),
'BeatmapsetCompact',
['beatmaps']
);
}

private function scoresBest($user, $mode, $perPage = 5, $offset = 0)
{
$scores = $user->scoresBest($mode, true)
Expand Down
14 changes: 14 additions & 0 deletions app/Models/User.php
Expand Up @@ -1325,6 +1325,20 @@ public function profileBeatmapsetsFavourite()
->with('beatmaps');
}

public function profileBeatmapsetsUnranked()
{
return $this->beatmapsets()
->unranked()
->with('beatmaps');
}

public function profileBeatmapsetsGraveyard()
{
return $this->beatmapsets()
->graveyard()
->with('beatmaps');
}

public function isValid()
{
$this->validationErrors()->reset();
Expand Down
20 changes: 20 additions & 0 deletions app/Transformers/UserTransformer.php
Expand Up @@ -33,6 +33,8 @@ class UserTransformer extends Fractal\TransformerAbstract
'page',
'recentActivities',
'rankedAndApprovedBeatmapsetCount',
'unrankedBeatmapsetCount',
'graveyardBeatmapsetCount',
'favouriteBeatmapsetCount',
'disqus_auth',
];
Expand Down Expand Up @@ -144,6 +146,24 @@ public function includeRankedAndApprovedBeatmapsetCount(User $user)
});
}

public function includeUnrankedBeatmapsetCount(User $user)
{
return $this->item($user, function ($user) {
return [
$user->profileBeatmapsetsUnranked()->count(),
];
});
}

public function includeGraveyardBeatmapsetCount(User $user)
{
return $this->item($user, function ($user) {
return [
$user->profileBeatmapsetsGraveyard()->count(),
];
});
}

public function includeFavouriteBeatmapsetCount(User $user)
{
return $this->item($user, function ($user) {
Expand Down
7 changes: 6 additions & 1 deletion resources/assets/coffee/react/profile-page/beatmaps.coffee
Expand Up @@ -24,6 +24,11 @@ class ProfilePage.Beatmaps extends React.PureComponent
allBeatmapsets =
favouriteBeatmapsets: @props.favouriteBeatmapsets
rankedAndApprovedBeatmapsets: @props.rankedAndApprovedBeatmapsets
unrankedBeatmapsets: @props.unrankedBeatmapsets
graveyardBeatmapsets: @props.graveyardBeatmapsets

perPage =
graveyardBeatmapsets: 2

div
className: 'page-extra'
Expand All @@ -50,7 +55,7 @@ class ProfilePage.Beatmaps extends React.PureComponent
collection: beatmapsets
propertyName: section
pagination: @props.pagination[section]
perPage: 6
perPage: perPage[section] ? 6
route: laroute.route 'users.beatmapsets',
user: @props.user.id
type: sectionSnaked
Expand Down
6 changes: 6 additions & 0 deletions resources/assets/coffee/react/profile-page/main.coffee
Expand Up @@ -57,6 +57,8 @@ class ProfilePage.Main extends React.PureComponent
beatmapPlaycounts: @props.beatmapsets.most_played
favouriteBeatmapsets: @props.beatmapsets.favourite
rankedAndApprovedBeatmapsets: @props.beatmapsets.ranked_and_approved
unrankedBeatmapsets: @props.beatmapsets.unranked
graveyardBeatmapsets: @props.beatmapsets.graveyard
recentlyReceivedKudosu: @props.recentlyReceivedKudosu
showMorePagination: {}

Expand Down Expand Up @@ -142,9 +144,13 @@ class ProfilePage.Main extends React.PureComponent
user: @state.user
favouriteBeatmapsets: @state.favouriteBeatmapsets
rankedAndApprovedBeatmapsets: @state.rankedAndApprovedBeatmapsets
unrankedBeatmapsets: @state.unrankedBeatmapsets
graveyardBeatmapsets: @state.graveyardBeatmapsets
counts:
favouriteBeatmapsets: @state.user.favouriteBeatmapsetCount[0]
rankedAndApprovedBeatmapsets: @state.user.rankedAndApprovedBeatmapsetCount[0]
unrankedBeatmapsets: @state.user.unrankedBeatmapsetCount[0]
graveyardBeatmapsets: @state.user.graveyardBeatmapsetCount[0]
pagination: @state.showMorePagination
component: ProfilePage.Beatmaps

Expand Down
24 changes: 14 additions & 10 deletions resources/lang/en/users.php
Expand Up @@ -96,7 +96,21 @@
'achieved-on' => 'Achieved on :date',
],
'beatmaps' => [
'none' => 'None... yet.',
'title' => 'Beatmaps',

'favourite' => [
'title' => 'Favourite Beatmaps (:count)',
],
'graveyard' => [
'title' => 'Graveyarded Beatmaps (:count)',
],
'ranked_and_approved' => [
'title' => 'Ranked & Approved Beatmaps (:count)',
],
'unranked' => [
'title' => 'Pending Beatmaps (:count)',
],
],
'historical' => [
'empty' => 'No performance records. :(',
Expand Down Expand Up @@ -174,16 +188,6 @@
'title' => 'Ranks',
'weighted_pp' => 'weighted: :pp (:percentage)',
],
'beatmaps' => [
'title' => 'Beatmaps',
'favourite' => [
'title' => 'Favourite Beatmaps (:count)',
],
'ranked_and_approved' => [
'title' => 'Ranked & Approved Beatmaps (:count)',
],
'none' => 'None... yet.',
],
],
'page' => [
'description' => '<strong>me!</strong> is a personal customisable area in your profile page.',
Expand Down
18 changes: 8 additions & 10 deletions resources/lang/es/users.php
Expand Up @@ -91,7 +91,15 @@
'achieved-on' => 'Obtenido el :date',
],
'beatmaps' => [
'none' => 'Ninguno... aún.',
'title' => 'Beatmaps',

'favourite' => [
'title' => 'Beatmaps Favoritos (:count)',
],
'ranked_and_approved' => [
'title' => 'Beatmaps Rankeados & Aprobados (:count)',
],
],
'historical' => [
'empty' => 'Sin récords de rendimiento. :(',
Expand Down Expand Up @@ -169,16 +177,6 @@
'title' => 'Rangos',
'weighted_pp' => 'valorado en: :pp (:percentage)',
],
'beatmaps' => [
'title' => 'Beatmaps',
'favourite' => [
'title' => 'Beatmaps Favoritos (:count)',
],
'ranked_and_approved' => [
'title' => 'Beatmaps Rankeados & Aprobados (:count)',
],
'none' => 'Ninguno... aún.',
],
],
'page' => [
'description' => '<strong>sobre mi!</strong> es una área personalizable en tu perfil.',
Expand Down
18 changes: 8 additions & 10 deletions resources/lang/fr/users.php
Expand Up @@ -95,7 +95,15 @@
'achieved-on' => 'Acquis le :date',
],
'beatmaps' => [
'none' => 'Aucune... Pour le moment.',
'title' => 'Beatmaps',

'favourite' => [
'title' => 'Beatmaps favorites (:count)',
],
'ranked_and_approved' => [
'title' => 'Beatmaps classées et approuvées (:count)',
],
],
'historical' => [
'empty' => 'Aucun enregistrement de performance. :(',
Expand Down Expand Up @@ -173,16 +181,6 @@
'title' => 'Classements',
'weighted_pp' => 'pondéré: :pp (:percentage)',
],
'beatmaps' => [
'title' => 'Beatmaps',
'favourite' => [
'title' => 'Beatmaps favorites (:count)',
],
'ranked_and_approved' => [
'title' => 'Beatmaps classées et approuvées (:count)',
],
'none' => 'Aucune... Pour le moment.',
],
],
'page' => [
'description' => '<strong>Moi!</strong> est une zone personnalisable du profil.',
Expand Down
20 changes: 9 additions & 11 deletions resources/lang/it/users.php
Expand Up @@ -83,7 +83,15 @@
'achieved-on' => 'Raggiunto il :date',
],
'beatmaps' => [
'title' => 'Beatmaps',
'none' => 'Nessuna... per ora.',
'title' => 'Beatmap',

'favourite' => [
'title' => 'Beatmaps Preferite (:count)',
],
'ranked_and_approved' => [
'title' => 'Beatmap Rankate e Approvate (:count)',
],
],
'historical' => [
'empty' => 'Nessuna registrazione della performance. :(', // record as "registrazione", like "we have no performance data to show you"
Expand Down Expand Up @@ -136,16 +144,6 @@
'title' => 'Rank',
'weighted_pp' => 'valutata: :pp (:percentage)', // "ponderata" - "pesata" - "valutata", i think "valutata" as "evalutated" is better
],
'beatmaps' => [
'title' => 'Beatmap',
'favourite' => [
'title' => 'Beatmaps Preferite (:count)',
],
'ranked_and_approved' => [
'title' => 'Beatmap Rankate e Approvate (:count)',
],
'none' => 'Nessuna... per ora.',
],
],
'page' => [
'description' => '<strong>io!</strong> è un\'area personale personalizzabile nella tua pagina del profilo.',
Expand Down
18 changes: 8 additions & 10 deletions resources/lang/ko/users.php
Expand Up @@ -96,7 +96,15 @@
'achieved-on' => ':date에 달성함',
],
'beatmaps' => [
'none' => '아직... 없네요...',
'title' => '비트맵',

'favourite' => [
'title' => '즐겨찾기한 비트맵 (:count개)',
],
'ranked_and_approved' => [
'title' => 'Ranked / Approved 된 비트맵 (:count개)',
],
],
'historical' => [
'empty' => '기록된 플레이가 없습니다. :(',
Expand Down Expand Up @@ -174,16 +182,6 @@
'title' => '순위',
'weighted_pp' => '가중치 적용: :pp (:percentage)', // 높은 경쟁력을 가진 맵(구맵들)은 가중치가 줄어들고 본래 pp에서 가중치를 곱한 만큼의 실 pp를 받게됨
],
'beatmaps' => [
'title' => '비트맵',
'favourite' => [
'title' => '즐겨찾기한 비트맵 (:count개)',
],
'ranked_and_approved' => [
'title' => 'Ranked / Approved 된 비트맵 (:count개)',
],
'none' => '아직... 없네요...',
],
],
'page' => [
'description' => '<strong>me!</strong>는 유저 프로필 페이지에서 개인이 꾸밀 수 있는 공간입니다.',
Expand Down
18 changes: 8 additions & 10 deletions resources/lang/nl/users.php
Expand Up @@ -80,7 +80,15 @@
'achieved-on' => 'Behaald op :date',
],
'beatmaps' => [
'none' => 'Nog geen...',
'title' => 'Beatmaps',

'favourite' => [
'title' => 'Favoriete Beatmaps (:count)',
],
'ranked_and_approved' => [
'title' => 'Gerankte & Goedgekeurde Beatmaps (:count)',
],
],
'historical' => [
'empty' => 'Geen prestatiegegevens. :(',
Expand Down Expand Up @@ -133,16 +141,6 @@
'title' => 'Ranks',
'weighted_pp' => 'gewogen: :pp (:percentage)',
],
'beatmaps' => [
'title' => 'Beatmaps',
'favourite' => [
'title' => 'Favoriete Beatmaps (:count)',
],
'ranked_and_approved' => [
'title' => 'Gerankte & Goedgekeurde Beatmaps (:count)',
],
'none' => 'Nog geen...',
],
],
'page' => [
'description' => '<strong>ik!</strong> is een persoonlijk bewerkbaar gedeelte van je profiel.',
Expand Down

0 comments on commit 3acd106

Please sign in to comment.