diff --git a/hypha/apply/funds/tables.py b/hypha/apply/funds/tables.py index b9824e84841123afec531a93b3327e4202c6e398..edf1b6c214df69741c79387ff405ea3c2e869f7c 100644 --- a/hypha/apply/funds/tables.py +++ b/hypha/apply/funds/tables.py @@ -421,6 +421,7 @@ class LeaderboardTable(tables.Table): 'most_recent', ] model = User + order_by = ('-total',) def render_most_recent(self, record): review = (Review.objects.filter(author__reviewer=record) diff --git a/hypha/apply/api/v1/templates/funds/review_leaderboard.html b/hypha/apply/funds/templates/funds/review_leaderboard.html similarity index 84% rename from hypha/apply/api/v1/templates/funds/review_leaderboard.html rename to hypha/apply/funds/templates/funds/review_leaderboard.html index 36131fa7015ee44d29bc1282cfdf09cccf5275e5..620bbeb76df667e0c2abd2b1d70634b4eac1f9ba 100644 --- a/hypha/apply/api/v1/templates/funds/review_leaderboard.html +++ b/hypha/apply/funds/templates/funds/review_leaderboard.html @@ -19,12 +19,9 @@ <div class="wrapper wrapper--large wrapper--inner-space-medium"> {% block table %} - {% include "funds/includes/table_filter_and_search.html" with filter_form=filter_form search_term=search_term use_search=True filter_action=filter_action use_batch_actions=False heading="All Submissions" %} + {% include "funds/includes/table_filter_and_search.html" with filter_form=filter_form search_term=search_term use_search=True filter_action=filter_action use_batch_actions=False heading="All reviewers" %} {% render_table table %} - <div class="all-submissions-table__more"> - <a href="{% url 'apply:submissions:list' %}">Show all</a> - </div> {% endblock %} </div> {% endblock %} diff --git a/hypha/apply/funds/templates/funds/submissions_overview.html b/hypha/apply/funds/templates/funds/submissions_overview.html index b83f169b8d51f75cb78d742ef53ffb4157eed90b..d954386f033e504e8bfe2019a04cc71aa4cdf741 100644 --- a/hypha/apply/funds/templates/funds/submissions_overview.html +++ b/hypha/apply/funds/templates/funds/submissions_overview.html @@ -13,6 +13,9 @@ {% if request.user.is_apply_staff %} <div class="tabs"> <div class="tabs__container"> + <a class="tab__item tab__item--right" href="{% url 'apply:submissions:leaderboard' %}"> + Leaderboard + </a> <a class="tab__item tab__item--right" href="{% url 'apply:submissions:result' %}"> Results </a> diff --git a/hypha/apply/funds/views.py b/hypha/apply/funds/views.py index 2061a89bf9c58a267460d5827109e689b9f1b9d8..9b951f00c3f7838fe20d5d80e5610ee43606cdad 100644 --- a/hypha/apply/funds/views.py +++ b/hypha/apply/funds/views.py @@ -1206,11 +1206,11 @@ class ReviewLeaderboard(SingleTableMixin, FilterView): ninety_days_ago = timezone.now() - timedelta(days=90) this_year = timezone.now().year last_year = timezone.now().year - 1 - latest_reviews = Review.objects.filter(author__reviewer_id=OuterRef('pk')).order_by('-created_at') + # latest_reviews = Review.objects.filter(author__reviewer_id=OuterRef('pk')).order_by('-created_at') return super().get_table_data().filter(submissions_reviewer__isnull=False).annotate( total=Count('assignedreviewers__review'), ninety_days=Count('assignedreviewers__review', filter=Q(assignedreviewers__review__created_at__date__gte=ninety_days_ago)), this_year=Count('assignedreviewers__review', filter=Q(assignedreviewers__review__created_at__year=this_year)), last_year=Count('assignedreviewers__review', filter=Q(assignedreviewers__review__created_at__year=last_year)), - most_recent=Subquery(latest_reviews.values('id')[:1]) + # most_recent=Subquery(latest_reviews.values('id')[:1]) ) diff --git a/hypha/apply/review/models.py b/hypha/apply/review/models.py index 0f91ec9def67aa6df9c0c0a339c9218fa5f455f3..6d782e85512b25adf15897b88c8bb6d987992066 100644 --- a/hypha/apply/review/models.py +++ b/hypha/apply/review/models.py @@ -101,6 +101,9 @@ class ReviewQuerySet(models.QuerySet): def by_partners(self): return self.submitted()._by_group(PARTNER_GROUP_NAME) + def by_user(self, user): + return self.submitted().filter(author__reviewer=user).order_by('-created_at') + def staff_score(self): return self.by_staff().score()