Skip to content

Commit

Permalink
stats: Bye stats_pe hello stats_ft
Browse files Browse the repository at this point in the history
  • Loading branch information
dejafait authored and rsebille committed Aug 22, 2024
1 parent 50f7205 commit 28b5c44
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 66 deletions.
8 changes: 4 additions & 4 deletions itou/templates/apply/list_of_available_exports.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h1>
<div class="s-section__container container">
<div class="row">
<div class="col-12">
{% if export_for == "siae" or can_view_stats_pe %}
{% if export_for == "siae" or can_view_stats_ft %}
<div class="c-info mb-3 mb-md-4" id="besoin-dun-chiffre">
<button class="c-info__summary collapsed" data-bs-toggle="collapse" data-bs-target="#collapseBesoinChiffre" aria-expanded="false" aria-controls="collapseBesoinChiffre">
<span>Besoin d'un chiffre ?</span>
Expand All @@ -57,15 +57,15 @@ <h1>
<div id="collapseBesoinChiffre" class="c-info__detail collapse">
Accédez aux <a href="{% url 'stats:stats_siae_hiring' %}" target="_blank" rel="noopener">données de recrutement de votre structure</a> (non nominatives) compilées, calculées et mises à jour quotidiennement.
</div>
{% elif export_for == "prescriptions" and can_view_stats_pe %}
{% elif export_for == "prescriptions" and can_view_stats_ft %}
<div id="collapseBesoinChiffre" class="c-info__detail collapse">
Accédez aux données de votre agence (non nominatives) compilées, calculées et mises à jour quotidiennement :
<ul class="mb-0">
<li>
<a href="{% url 'stats:stats_pe_state_main' %}" target="_blank" rel="noopener">Voir les données de l'ensemble de l'état des candidatures orientées</a>
<a href="{% url 'stats:stats_ft_state_main' %}" target="_blank" rel="noopener">Voir les données de l'ensemble de l'état des candidatures orientées</a>
</li>
<li>
<a href="{% url 'stats:stats_pe_conversion_main' %}" target="_blank" rel="noopener">Voir les données du taux de transformation des candidatures</a>
<a href="{% url 'stats:stats_ft_conversion_main' %}" target="_blank" rel="noopener">Voir les données du taux de transformation des candidatures</a>
</li>
</ul>
</div>
Expand Down
10 changes: 5 additions & 5 deletions itou/templates/dashboard/includes/stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
</a>
</li>
{% endif %}
{% if can_view_stats_pe %}
{% if can_view_stats_ft %}
<li class="d-flex justify-content-between align-items-center mb-3">
<a href="https://plateforme-inclusion.notion.site/Guide-d-utilisation-et-d-analyse-des-tableaux-de-bord-France-Travail-dad8530e64af47bd99787a6d4e81f6b9"
rel="noopener"
Expand All @@ -111,25 +111,25 @@
</a>
</li>
<li class="d-flex justify-content-between align-items-center mb-3">
<a href="{% url 'stats:stats_pe_state_main' %}" class="btn-link btn-ico">
<a href="{% url 'stats:stats_ft_state_main' %}" class="btn-link btn-ico">
<i class="ri-bar-chart-line ri-lg font-weight-normal align-self-start"></i>
<span>Traitement et résultat des candidatures orientées par mes agences</span>
</a>
</li>
<li class="d-flex justify-content-between align-items-center mb-3">
<a href="{% url 'stats:stats_pe_conversion_main' %}" class="btn-link btn-ico">
<a href="{% url 'stats:stats_ft_conversion_main' %}" class="btn-link btn-ico">
<i class="ri-bar-chart-line ri-lg font-weight-normal align-self-start"></i>
<span>Taux de transformation de mes agences</span>
</a>
</li>
<li class="d-flex justify-content-between align-items-center mb-3">
<a href="{% url 'stats:stats_pe_tension' %}" class="btn-link btn-ico">
<a href="{% url 'stats:stats_ft_tension' %}" class="btn-link btn-ico">
<i class="ri-bar-chart-line ri-lg font-weight-normal align-self-start"></i>
<span>Fiches de poste en tension de mon territoire</span>
</a>
</li>
<li class="d-flex justify-content-between align-items-center mb-3">
<a href="{% url 'stats:stats_pe_delay_main' %}" class="btn-link btn-ico">
<a href="{% url 'stats:stats_ft_delay_main' %}" class="btn-link btn-ico">
<i class="ri-bar-chart-line ri-lg font-weight-normal align-self-start"></i>
<span>Délai d'entrée en IAE pour mon territoire</span>
</a>
Expand Down
16 changes: 8 additions & 8 deletions itou/utils/apis/metabase.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,33 +84,33 @@
"dashboard_id": 327,
},
#
# Prescriber stats - PE.
# Prescriber stats - FT.
#
"stats_pe_delay_main": {
"stats_ft_delay_main": {
"dashboard_id": 168,
"tally_popup_form_id": "3lb9XW",
"tally_embed_form_id": "meM7DE",
},
"stats_pe_delay_raw": {
"stats_ft_delay_raw": {
"dashboard_id": 180,
},
"stats_pe_conversion_main": {
"stats_ft_conversion_main": {
"dashboard_id": 169,
"tally_popup_form_id": "mODeK8",
"tally_embed_form_id": "3xrPjJ",
},
"stats_pe_conversion_raw": {
"stats_ft_conversion_raw": {
"dashboard_id": 182,
},
"stats_pe_state_main": {
"stats_ft_state_main": {
"dashboard_id": 149,
"tally_popup_form_id": "mRG61J",
"tally_embed_form_id": "3qLKad",
},
"stats_pe_state_raw": {
"stats_ft_state_raw": {
"dashboard_id": 183,
},
"stats_pe_tension": {
"stats_ft_tension": {
"dashboard_id": 162,
"tally_popup_form_id": "wobaYV",
"tally_embed_form_id": "3EKJ5q",
Expand Down
4 changes: 2 additions & 2 deletions itou/www/apply/views/list_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
FilterJobApplicationsForm,
PrescriberFilterJobApplicationsForm,
)
from itou.www.stats.utils import can_view_stats_pe
from itou.www.stats.utils import can_view_stats_ft


class JobApplicationsListKind(enum.Enum):
Expand Down Expand Up @@ -182,7 +182,7 @@ def list_prescriptions_exports(request, template_name="apply/list_of_available_e
"job_applications_by_month": job_applications_by_month,
"total_job_applications": total_job_applications,
"export_for": "prescriptions",
"can_view_stats_pe": can_view_stats_pe(request),
"can_view_stats_ft": can_view_stats_ft(request),
"back_url": get_safe_url(request, "back_url", reverse("dashboard:index")),
}
return render(request, template_name, context)
Expand Down
2 changes: 1 addition & 1 deletion itou/www/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def dashboard(request, template_name="dashboard/dashboard.html"):
"can_view_stats_cd": stats_utils.can_view_stats_cd(request),
"can_view_stats_cd_whitelist": stats_utils.can_view_stats_cd_whitelist(request),
"can_view_stats_cd_aci": stats_utils.can_view_stats_cd_aci(request),
"can_view_stats_pe": stats_utils.can_view_stats_pe(request),
"can_view_stats_ft": stats_utils.can_view_stats_ft(request),
"can_view_stats_ph": stats_utils.can_view_stats_ph(request),
"can_view_stats_ddets_iae": stats_utils.can_view_stats_ddets_iae(request),
"can_view_stats_ddets_iae_aci": stats_utils.can_view_stats_ddets_iae_aci(request),
Expand Down
17 changes: 9 additions & 8 deletions itou/www/stats/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
path("cd/hiring", views.stats_cd_hiring, name="stats_cd_hiring"),
path("cd/brsa", views.stats_cd_brsa, name="stats_cd_brsa"),
path("cd/aci", views.stats_cd_aci, name="stats_cd_aci"),
# Prescriber stats - PE.
path("pe/delay/main", views.stats_pe_delay_main, name="stats_pe_delay_main"),
path("pe/delay/raw", views.stats_pe_delay_raw, name="stats_pe_delay_raw"),
path("pe/conversion/main", views.stats_pe_conversion_main, name="stats_pe_conversion_main"),
path("pe/conversion/raw", views.stats_pe_conversion_raw, name="stats_pe_conversion_raw"),
path("pe/state/main", views.stats_pe_state_main, name="stats_pe_state_main"),
path("pe/state/raw", views.stats_pe_state_raw, name="stats_pe_state_raw"),
path("pe/tension", views.stats_pe_tension, name="stats_pe_tension"),
# Prescriber stats - FT.
# Legacy `pe` term is used in URLs for retroactivity in Matomo stats but in fact it means `ft`.
path("pe/delay/main", views.stats_ft_delay_main, name="stats_ft_delay_main"),
path("pe/delay/raw", views.stats_ft_delay_raw, name="stats_ft_delay_raw"),
path("pe/conversion/main", views.stats_ft_conversion_main, name="stats_ft_conversion_main"),
path("pe/conversion/raw", views.stats_ft_conversion_raw, name="stats_ft_conversion_raw"),
path("pe/state/main", views.stats_ft_state_main, name="stats_ft_state_main"),
path("pe/state/raw", views.stats_ft_state_raw, name="stats_ft_state_raw"),
path("pe/tension", views.stats_ft_tension, name="stats_ft_tension"),
# Authorized prescribers' stats
path("ph/state/main", views.stats_ph_state_main, name="stats_ph_state_main"),
# Institution stats - DDETS IAE - department level.
Expand Down
6 changes: 3 additions & 3 deletions itou/www/stats/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def can_view_stats_cd_aci(request):
)


def can_view_stats_pe(request):
def can_view_stats_ft(request):
return (
request.user.is_prescriber
and isinstance(request.current_organization, PrescriberOrganization)
Expand Down Expand Up @@ -218,8 +218,8 @@ def can_view_stats_iae_network(request):
)


def get_stats_pe_departments(request):
if not can_view_stats_pe(request):
def get_stats_ft_departments(request):
if not can_view_stats_ft(request):
raise PermissionDenied
if request.current_organization.is_dgft:
return DEPARTMENTS.keys()
Expand Down
36 changes: 18 additions & 18 deletions itou/www/stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,19 +365,19 @@ def stats_cd_aci(request):
)


def render_stats_pe(request, page_title, extra_params=None):
def render_stats_ft(request, page_title, extra_params=None):
"""
PE ("Pôle emploi") stats shown to relevant members.
FT ("France Travail") stats shown to relevant members.
They can view data for their whole departement, not only their agency.
They cannot view data for other departments than their own.
`*_main` views are linked directly from the C1 dashboard.
`*_raw` views are not directly visible on the C1 dashboard but are linked from within their `*_main` counterpart.
"""
current_org = get_current_org_or_404(request)
if not utils.can_view_stats_pe(request):
if not utils.can_view_stats_ft(request):
raise PermissionDenied
departments = utils.get_stats_pe_departments(request)
departments = utils.get_stats_ft_departments(request)
params = {
mb.DEPARTMENT_FILTER_KEY: [DEPARTMENTS[d] for d in departments],
}
Expand Down Expand Up @@ -412,8 +412,8 @@ def render_stats_pe(request, page_title, extra_params=None):


@login_required
def stats_pe_delay_main(request):
return render_stats_pe(
def stats_ft_delay_main(request):
return render_stats_ft(
request=request,
page_title="Délai d'entrée en IAE",
extra_params={
Expand All @@ -423,17 +423,17 @@ def stats_pe_delay_main(request):


@login_required
def stats_pe_delay_raw(request):
return render_stats_pe(
def stats_ft_delay_raw(request):
return render_stats_ft(
request=request,
page_title="Données brutes de délai d'entrée en IAE",
# No additional locked filter is needed for these PE stats.
)


@login_required
def stats_pe_conversion_main(request):
return render_stats_pe(
def stats_ft_conversion_main(request):
return render_stats_ft(
request=request,
page_title="Taux de transformation",
extra_params={
Expand All @@ -443,8 +443,8 @@ def stats_pe_conversion_main(request):


@login_required
def stats_pe_conversion_raw(request):
return render_stats_pe(
def stats_ft_conversion_raw(request):
return render_stats_ft(
request=request,
page_title="Données brutes du taux de transformation",
extra_params={
Expand All @@ -454,8 +454,8 @@ def stats_pe_conversion_raw(request):


@login_required
def stats_pe_state_main(request):
return render_stats_pe(
def stats_ft_state_main(request):
return render_stats_ft(
request=request,
page_title="Etat des candidatures orientées",
extra_params={
Expand All @@ -465,8 +465,8 @@ def stats_pe_state_main(request):


@login_required
def stats_pe_state_raw(request):
return render_stats_pe(
def stats_ft_state_raw(request):
return render_stats_ft(
request=request,
page_title="Données brutes de l’état des candidatures orientées",
extra_params={
Expand All @@ -476,8 +476,8 @@ def stats_pe_state_raw(request):


@login_required
def stats_pe_tension(request):
return render_stats_pe(
def stats_ft_tension(request):
return render_stats_ft(
request=request,
page_title="Fiches de poste en tension",
# No additional locked filter is needed for these PE stats.
Expand Down
30 changes: 15 additions & 15 deletions tests/www/stats/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def test_can_view_stats_cd_aci(settings):
assert utils.can_view_stats_dashboard_widget(request)


def test_can_view_stats_pe_as_regular_pe_agency():
def test_can_view_stats_ft_as_regular_pe_agency():
regular_pe_agency = PrescriberOrganizationWithMembershipFactory(
authorized=True, kind=PrescriberOrganizationKind.PE, department="93"
)
Expand All @@ -185,11 +185,11 @@ def test_can_view_stats_pe_as_regular_pe_agency():
assert not regular_pe_agency.is_drft
assert not regular_pe_agency.is_dgft
request = get_request(user)
assert utils.can_view_stats_pe(request)
assert utils.get_stats_pe_departments(request) == ["93"]
assert utils.can_view_stats_ft(request)
assert utils.get_stats_ft_departments(request) == ["93"]


def test_can_view_stats_pe_as_dtft_with_single_department():
def test_can_view_stats_ft_as_dtft_with_single_department():
dtft_with_single_department = PrescriberOrganizationWithMembershipFactory(
authorized=True,
kind=PrescriberOrganizationKind.PE,
Expand All @@ -201,11 +201,11 @@ def test_can_view_stats_pe_as_dtft_with_single_department():
assert not dtft_with_single_department.is_drft
assert not dtft_with_single_department.is_dgft
request = get_request(user)
assert utils.can_view_stats_pe(request)
assert utils.get_stats_pe_departments(request) == ["49"]
assert utils.can_view_stats_ft(request)
assert utils.get_stats_ft_departments(request) == ["49"]


def test_can_view_stats_pe_as_dtft_with_multiple_departments():
def test_can_view_stats_ft_as_dtft_with_multiple_departments():
dtft_with_multiple_departments = PrescriberOrganizationWithMembershipFactory(
authorized=True,
kind=PrescriberOrganizationKind.PE,
Expand All @@ -217,11 +217,11 @@ def test_can_view_stats_pe_as_dtft_with_multiple_departments():
assert not dtft_with_multiple_departments.is_drft
assert not dtft_with_multiple_departments.is_dgft
request = get_request(user)
assert utils.can_view_stats_pe(request)
assert utils.get_stats_pe_departments(request) == ["72", "53"]
assert utils.can_view_stats_ft(request)
assert utils.get_stats_ft_departments(request) == ["72", "53"]


def test_can_view_stats_pe_as_drft():
def test_can_view_stats_ft_as_drft():
drft = PrescriberOrganizationWithMembershipFactory(
authorized=True,
kind=PrescriberOrganizationKind.PE,
Expand All @@ -233,8 +233,8 @@ def test_can_view_stats_pe_as_drft():
assert not drft.is_dgft
assert not drft.is_dtft
request = get_request(user)
assert utils.can_view_stats_pe(request)
assert utils.get_stats_pe_departments(request) == [
assert utils.can_view_stats_ft(request)
assert utils.get_stats_ft_departments(request) == [
"75",
"77",
"78",
Expand All @@ -246,7 +246,7 @@ def test_can_view_stats_pe_as_drft():
]


def test_can_view_stats_pe_as_dgft():
def test_can_view_stats_ft_as_dgft():
dgft = PrescriberOrganizationWithMembershipFactory(
authorized=True,
kind=PrescriberOrganizationKind.PE,
Expand All @@ -258,8 +258,8 @@ def test_can_view_stats_pe_as_dgft():
assert not dgft.is_dtft
assert dgft.is_dgft
request = get_request(user)
assert utils.can_view_stats_pe(request)
assert utils.get_stats_pe_departments(request)
assert utils.can_view_stats_ft(request)
assert utils.get_stats_ft_departments(request)


@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletions tests/www/stats/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def assert_stats_dashboard_equal(values):
@override_settings(METABASE_SITE_URL="http://metabase.fake", METABASE_SECRET_KEY="foobar")
@pytest.mark.parametrize(
"view_name",
[p.name for p in stats_urls.urlpatterns if p.name.startswith("stats_pe_")],
[p.name for p in stats_urls.urlpatterns if p.name.startswith("stats_ft_")],
)
def test_stats_pe_log_visit(client, view_name):
def test_stats_ft_log_visit(client, view_name):
prescriber_org = PrescriberOrganizationWithMembershipFactory(kind="PE", authorized=True)
user = prescriber_org.members.get()
client.force_login(user)
Expand Down

0 comments on commit 28b5c44

Please sign in to comment.