Skip to content

Reviewer leaderboard

hypha.apply.funds.views.reviewer_leaderboard

User module-attribute

User = get_user_model()

ReviewerLeaderboard

Bases: SingleTableMixin, FilterView

filterset_class class-attribute instance-attribute

filterset_class = ReviewerLeaderboardFilter

filter_action class-attribute instance-attribute

filter_action = ''

table_class class-attribute instance-attribute

table_pagination class-attribute instance-attribute

table_pagination = False

template_name class-attribute instance-attribute

template_name = 'funds/reviewer_leaderboard.html'

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views/reviewer_leaderboard.py
def get_context_data(self, **kwargs):
    search_term = self.request.GET.get("query")

    return super().get_context_data(
        search_term=search_term,
        filter_action=self.filter_action,
        **kwargs,
    )

get_queryset

get_queryset()
Source code in hypha/apply/funds/views/reviewer_leaderboard.py
def get_queryset(self):
    # Only list reviewers.
    return self.filterset_class._meta.model.objects.reviewers()

get_table_data

get_table_data()
Source code in hypha/apply/funds/views/reviewer_leaderboard.py
def get_table_data(self):
    ninety_days_ago = timezone.now() - timedelta(days=90)
    this_year = timezone.now().year
    last_year = timezone.now().year - 1
    return (
        super()
        .get_table_data()
        .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),
            ),
        )
    )

ReviewerLeaderboardDetail

Bases: SingleTableMixin, ListView

model class-attribute instance-attribute

model = Review

table_class class-attribute instance-attribute

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

template_name class-attribute instance-attribute

template_name = 'funds/reviewer_leaderboard_detail.html'

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views/reviewer_leaderboard.py
def get_context_data(self, **kwargs):
    obj = User.objects.get(pk=self.kwargs.get("pk"))
    return super().get_context_data(object=obj, **kwargs)

get_table_data

get_table_data()
Source code in hypha/apply/funds/views/reviewer_leaderboard.py
def get_table_data(self):
    return (
        super()
        .get_table_data()
        .filter(author__reviewer_id=self.kwargs.get("pk"))
        .select_related("submission")
    )