diff --git a/src/statistics/datasets.tsx b/src/statistics/datasets.tsx index 48e34b12..2227fb99 100644 --- a/src/statistics/datasets.tsx +++ b/src/statistics/datasets.tsx @@ -117,6 +117,9 @@ export const datasets: { [key: string]: Dataset } = { }, [datasetNumberOfShiftPartners]: { display_name: gettext("Shift partners"), + description: gettext( + "Counted out of working members only: a frozen member with a shift partner is not counted", + ), apiCall: api.statisticsNumberOfShiftPartnersAtDateRetrieve, chart_type: "line", relative: false, diff --git a/tapir/statistics/views/fancy_graph/number_of_shift_partners_view.py b/tapir/statistics/views/fancy_graph/number_of_shift_partners_view.py index c799ecad..5c9aafbd 100644 --- a/tapir/statistics/views/fancy_graph/number_of_shift_partners_view.py +++ b/tapir/statistics/views/fancy_graph/number_of_shift_partners_view.py @@ -1,18 +1,18 @@ -from tapir.coop.models import ShareOwner, MemberStatus -from tapir.shifts.models import ShiftUserData from tapir.shifts.services.shift_partner_history_service import ( ShiftPartnerHistoryService, ) -from tapir.statistics.views.fancy_graph.base_view import DatapointView +from tapir.statistics.views.fancy_graph.base_view import ( + DatapointView, + get_shift_user_datas_of_working_members_annotated_with_attendance_mode, +) class NumberOfShiftPartnersAtDateView(DatapointView): def get_datapoint(self, reference_time) -> int: - active_members = ShareOwner.objects.with_status( - MemberStatus.ACTIVE, reference_time - ) - shift_user_datas = ShiftUserData.objects.filter( - user__share_owner__in=active_members + shift_user_datas = ( + get_shift_user_datas_of_working_members_annotated_with_attendance_mode( + reference_time + ) ) shift_user_datas = ShiftPartnerHistoryService.annotate_shift_user_data_queryset_with_has_shift_partner_at_date(