Skip to content

Commit

Permalink
refactor(stats): renommage de l'app forum_stats en stats (#690)
Browse files Browse the repository at this point in the history
## Description

🎸 Eviter les ambiguités de nom avec les nouveaux modèles de #599 

## Type de changement

🚧 technique
  • Loading branch information
vincentporte authored Jun 19, 2024
1 parent 7471451 commit 50b6937
Show file tree
Hide file tree
Showing 31 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"lacommunaute.forum_conversation.forum_polls",
"lacommunaute.forum_member",
"lacommunaute.forum_upvote",
"lacommunaute.forum_stats",
"lacommunaute.stats",
"lacommunaute.forum_moderation",
"lacommunaute.notification",
"lacommunaute.event",
Expand Down
4 changes: 2 additions & 2 deletions config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
from lacommunaute.forum_conversation.forum_polls import urls as forum_polls_extension_urls
from lacommunaute.forum_member import urls as forum_member_urls
from lacommunaute.forum_moderation import urls as forum_moderation_urls
from lacommunaute.forum_stats import urls as forum_stats_urls
from lacommunaute.forum_upvote import urls as forum_upvote_urls
from lacommunaute.inclusion_connect import urls as inclusion_connect_urls
from lacommunaute.pages import urls as pages_urls
from lacommunaute.search import urls as search_urls
from lacommunaute.stats import urls as stats_urls
from lacommunaute.surveys import urls as surveys_urls


Expand All @@ -38,7 +38,7 @@
path("", include(forum_moderation_urls)),
path("calendar/", include(event_urls)),
path("surveys/", include(surveys_urls)),
path("statistiques/", include(forum_stats_urls)),
path("statistiques/", include(stats_urls)),
# machina legacy
path("", include(conversation_urlpatterns_factory.urlpatterns)),
path("moderation/", include(moderation_urlpatterns_factory.urlpatterns)),
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/forum/tests/test_categoryforum_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_context(client, db):
url = reverse("forum_extension:documentation")
response = client.get(url)
assert "forum/category_forum_list.html" == response.templates[0].name
assertContains(response, reverse("forum_stats:statistiques"), status_code=200)
assertContains(response, reverse("stats:statistiques"), status_code=200)


def test_queryset(client, db):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.contrib import admin

from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.models import Stat


class StatAdmin(admin.ModelAdmin):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


class ForumStatsAppConfig(AppConfig):
label = "forum_stats"
name = "lacommunaute.forum_stats"
label = "stats"
name = "lacommunaute.stats"
verbose_name = "Forum Stats"
verbose_name_plural = "Forum Stats"
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import factory
import factory.django

from lacommunaute.forum_stats.enums import Period
from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.enums import Period
from lacommunaute.stats.models import Stat


class StatFactory(factory.django.DjangoModelFactory):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from dateutil.relativedelta import relativedelta
from django.core.management.base import BaseCommand

from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.models import Stat
from lacommunaute.utils.matomo import collect_stats_from_matomo_api


Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.db import models

from lacommunaute.forum_stats.enums import Period
from lacommunaute.stats.enums import Period


class StatQuerySet(models.QuerySet):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest # noqa
from lacommunaute.forum_stats.management.commands.collect_matomo_stats import get_initial_from_date
from lacommunaute.stats.management.commands.collect_matomo_stats import get_initial_from_date
from django.core.management import call_command
from lacommunaute.surveys.factories import DSPFactory
from lacommunaute.forum_stats.factories import StatFactory
from lacommunaute.stats.factories import StatFactory


def test_collect_django_stats(db, capsys):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from django.utils import timezone
from django.utils.timezone import localdate

from lacommunaute.forum_stats.enums import Period
from lacommunaute.forum_stats.factories import StatFactory
from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.enums import Period
from lacommunaute.stats.factories import StatFactory
from lacommunaute.stats.models import Stat


class StatModelTest(TestCase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from machina.core.loading import get_class
from pytest_django.asserts import assertContains

from lacommunaute.forum_stats.enums import Period
from lacommunaute.forum_stats.factories import StatFactory
from lacommunaute.stats.enums import Period
from lacommunaute.stats.factories import StatFactory
from lacommunaute.surveys.factories import DSPFactory
from lacommunaute.utils.math import percent
from lacommunaute.utils.testing import parse_response_to_soup
Expand All @@ -21,7 +21,7 @@

class StatistiquesPageTest(TestCase):
def test_context_data(self):
url = reverse("forum_stats:statistiques")
url = reverse("stats:statistiques")
date = timezone.now()
names = ["nb_uniq_engaged_visitors", "nb_uniq_visitors", "nb_uniq_active_visitors"]
for name in names:
Expand All @@ -35,7 +35,7 @@ def test_context_data(self):

response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertTemplateUsed(response, "forum_stats/statistiques.html")
self.assertTemplateUsed(response, "stats/statistiques.html")

# expected values
self.assertIn("stats", response.context)
Expand All @@ -51,7 +51,7 @@ def test_context_data(self):

def test_month_datas_in_context(self):
today = localdate()
url = reverse("forum_stats:statistiques")
url = reverse("stats:statistiques")

# no data
response = self.client.get(url)
Expand Down Expand Up @@ -92,7 +92,7 @@ def test_month_datas_in_context(self):
)

def test_impact_in_context_data(self):
url = reverse("forum_stats:statistiques")
url = reverse("stats:statistiques")
today = localdate()
empty_res = {"date": [], "nb_uniq_visitors_returning": []}

Expand All @@ -116,23 +116,23 @@ def test_impact_in_context_data(self):
self.assertEqual(response.context["impact"]["nb_uniq_visitors_returning"][0], 1)

def test_navigation(self):
url = reverse("forum_stats:statistiques")
url = reverse("stats:statistiques")
response = self.client.get(url)
self.assertContains(response, f"<a href={reverse('forum_stats:monthly_visitors')}>")
self.assertContains(response, f"<a href={reverse('stats:monthly_visitors')}>")


class TestStatistiquesPageView:
def test_dsp_count(self, client, db, snapshot):
DSPFactory.create_batch(10)
url = reverse("forum_stats:statistiques")
url = reverse("stats:statistiques")
response = client.get(url)
assert response.status_code == 200
assert str(parse_response_to_soup(response, selector="#daily_dsp")) == snapshot(name="dsp")


class TestMonthlyVisitorsView:
def test_context_data(self, client, db):
url = reverse("forum_stats:monthly_visitors")
url = reverse("stats:monthly_visitors")
today = localdate()
empty_res = {
"date": [],
Expand Down Expand Up @@ -171,7 +171,7 @@ def test_context_data(self, client, db):
}

def test_navigation(self, client, db, snapshot):
url = reverse("forum_stats:dsp")
url = reverse("stats:dsp")
response = client.get(url)
assert response.status_code == 200
assert str(parse_response_to_soup(response, selector=".c-breadcrumb")) == snapshot(name="breadcrumb")
Expand All @@ -191,7 +191,7 @@ def test_context_data(self, client, db):
)
StatFactory(name="dsp", period=Period.DAY, date=today, value=2)

url = reverse("forum_stats:dsp")
url = reverse("stats:dsp")
response = client.get(url)
assert response.status_code == 200
assert response.context["box_title"] == "Diagnostics Parcours IAE quotidiens"
Expand All @@ -204,7 +204,7 @@ def test_context_data(self, client, db):
}

def test_navigation(self, client, db, snapshot):
url = reverse("forum_stats:dsp")
url = reverse("stats:dsp")
response = client.get(url)
assert response.status_code == 200
assert str(parse_response_to_soup(response, selector=".c-breadcrumb")) == snapshot(name="breadcrumb")
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from django.urls import path

from lacommunaute.forum_stats.views import DailyDSPView, MonthlyVisitorsView, StatistiquesPageView
from lacommunaute.stats.views import DailyDSPView, MonthlyVisitorsView, StatistiquesPageView


app_name = "forum_stats"
app_name = "stats"

urlpatterns = [
path("", StatistiquesPageView.as_view(), name="statistiques"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.utils.timezone import localdate
from django.views.generic.base import TemplateView

from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.models import Stat
from lacommunaute.surveys.models import DSP
from lacommunaute.utils.json import extract_values_in_list
from lacommunaute.utils.math import percent
Expand All @@ -18,7 +18,7 @@


class StatistiquesPageView(TemplateView):
template_name = "forum_stats/statistiques.html"
template_name = "stats/statistiques.html"

def get_funnel_data(self):
qs = Stat.objects.current_month_datas()
Expand Down Expand Up @@ -101,7 +101,7 @@ def get_context_data(self, **kwargs):


class MonthlyVisitorsView(BaseDetailStatsView):
template_name = "forum_stats/monthly_visitors.html"
template_name = "stats/monthly_visitors.html"
box_title = "Utilisateurs uniques mensuels"
indicator_names = [
"nb_uniq_visitors",
Expand All @@ -114,7 +114,7 @@ class MonthlyVisitorsView(BaseDetailStatsView):


class DailyDSPView(BaseDetailStatsView):
template_name = "forum_stats/daily_dsp.html"
template_name = "stats/daily_dsp.html"
box_title = "Diagnostics Parcours IAE quotidiens"
indicator_names = ["dsp"]
period = "day"
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/surveys/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.db.models.functions import TruncDate
from django.utils import timezone

from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.models import Stat
from lacommunaute.surveys.models import DSP


Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/surveys/tests/test_stats.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest # noqa
from datetime import datetime, date
from dateutil.relativedelta import relativedelta
from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.models import Stat
from lacommunaute.surveys.factories import DSPFactory
from lacommunaute.surveys.stats import collect_dsp_stats

Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/templates/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<a href="{% url 'pages:politique_de_confidentialite' %}" aria-label="Politique de confidentialité">Politique de confidentialité</a>
</li>
<li>
<a href="{% url 'forum_stats:statistiques' %}">Statistiques</a>
<a href="{% url 'stats:statistiques' %}">Statistiques</a>
</li>
</ul>
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<ol class="breadcrumb">
<li class="breadcrumb-item">{% trans "Back to" %}</li>
<li class="breadcrumb-item">
<a href="{% url 'forum_stats:statistiques' %}">Statistiques</a>
<a href="{% url 'stats:statistiques' %}">Statistiques</a>
</li>
</ol>
</nav>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2>Acquisition</h2>
<span class="fs-sm">{{ engagement_percent }}% des util. actifs</span>
</div>
<figcaption class="fs-sm text-muted mt-3">
Période : <a href={% url 'forum_stats:monthly_visitors' %}>{{ period }}</a>
Période : <a href={% url 'stats:monthly_visitors' %}>{{ period }}</a>
</figcaption>
</figure>
</div>
Expand Down Expand Up @@ -92,7 +92,7 @@ <h2>Vue quotidienne</h2>
<h2>{{ dsp_count }} Diagnostique{{ dsp_count|pluralizefr }} Parcours IAE</h2>
<p>
Réalisé{{ dsp_count|pluralizefr }} sur la communauté de l'inclusion depuis le 24 février 2024
<span class="fs-sm">(<a href={% url 'forum_stats:dsp' %}>Voir les détails</a>)</span>
<span class="fs-sm">(<a href={% url 'stats:dsp' %}>Voir les détails</a>)</span>
</p>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion lacommunaute/utils/matomo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from dateutil.relativedelta import relativedelta
from django.conf import settings

from lacommunaute.forum_stats.models import Stat
from lacommunaute.stats.models import Stat


def get_matomo_data(
Expand Down

0 comments on commit 50b6937

Please sign in to comment.