Skip to content

Commit

Permalink
Fix articles per year issue when there is no data
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorfs committed Mar 11, 2020
1 parent f0135f8 commit 437c539
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions parsifal/reviews/conducting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,14 @@ def articles_selection_chart(request):

def articles_per_year(request):
review_id = request.GET['review-id']
review = Review.objects.get(pk=review_id)
review = get_object_or_404(Review, pk=review_id)
final_articles = review.get_final_selection_articles().values('year').annotate(count=Count('year')).order_by('-year')
articles = []
for article in final_articles:
articles.append(article['year'] + ':' + str(article['count']))
try:
articles.append(article['year'] + ':' + str(article['count']))
except Exception:
pass
return HttpResponse(','.join(articles))

@author_required
Expand Down

0 comments on commit 437c539

Please sign in to comment.