Skip to content

Commit

Permalink
Fix issue in chunking likes in groups of 6 that caused error. Fix boj…
Browse files Browse the repository at this point in the history
  • Loading branch information
olberger committed Apr 7, 2017
1 parent c70ef15 commit d47c4ad
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 8 additions & 4 deletions app/views/profile.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,18 @@
<div class="container">
{% for likeGroup in groupedLikes %}
<div class="row">
{% for like in likeGroup %}
<div class="span2">
{% for like in likeGroup %}
{% if like.artist is not empty %}
<div class="span2">

<a href="{{ path('artist', {'artist': like.artist.id}) }}" class="amazing_image">
<h6 class="photo_hover">{{ like.artist.name }}</h6>
<img src="{{ app.request.basepath }}/img/artists/{{ like.artist.image }}">
</a>
</div>
{% endfor %}

</div>
{% endif %}
{% endfor %}
</div>
{% endfor %}
</div>
Expand Down
9 changes: 2 additions & 7 deletions src/MusicBox/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,8 @@ public function meAction(Request $request, Application $app)
$likes = $app['repository.like']->findAllByUser($user->getId(), $limit);
// Divide artists into groups of 6.
$groupSize = 6;
$groupedLikes = array();
$progress = 0;
while ($progress < $limit) {
$groupedLikes[] = array_slice($likes, $progress, $groupSize);
$progress += $groupSize;
}

$groupedLikes = array_chunk($likes, $groupSize);

$data = array(
'user' => $user,
'memberSince' => $memberSince,
Expand Down

0 comments on commit d47c4ad

Please sign in to comment.