diff --git a/lemarche/tenders/management/commands/update_tender_count_fields.py b/lemarche/tenders/management/commands/update_tender_count_fields.py index e5939cf4c..3aab00a83 100644 --- a/lemarche/tenders/management/commands/update_tender_count_fields.py +++ b/lemarche/tenders/management/commands/update_tender_count_fields.py @@ -4,6 +4,11 @@ TENDER_COUNT_FIELDS = [ "siae_count", + "siae_email_send_count", + "siae_email_link_click_count", + "siae_detail_display_count", + "siae_email_link_click_or_detail_display_count", + "siae_detail_contact_click_count", ] @@ -15,7 +20,7 @@ class Command(BaseCommand): python manage.py update_tender_count_fields python manage.py update_tender_count_fields --id 1 python manage.py update_tender_count_fields --id 1 --fields siae_count - python manage.py update_tender_count_fields --id 1 --fields siae_count --fields siae_count + python manage.py update_tender_count_fields --id 1 --fields siae_count --fields siae_detail_contact_click_count """ def add_arguments(self, parser): @@ -42,6 +47,13 @@ def handle(self, *args, **options): for index, tender in enumerate(tender_queryset): # M2M tender.siae_count = tender.siae_count_annotated + tender.siae_email_send_count = tender.siae_email_send_count_annotated + tender.siae_email_link_click_count = tender.siae_email_link_click_count_annotated + tender.siae_detail_display_count = tender.siae_detail_display_count_annotated + tender.siae_email_link_click_or_detail_display_count = ( + tender.siae_email_link_click_or_detail_display_count_annotated + ) + tender.siae_detail_contact_click_count = tender.siae_detail_contact_click_count_annotated # Step 3: update count fields tender.save(update_fields=update_fields) diff --git a/lemarche/tenders/migrations/0059_tender_siae_count_updated.py b/lemarche/tenders/migrations/0059_tender_siae_count_updated.py index 8af0e07fa..c6faaebc4 100644 --- a/lemarche/tenders/migrations/0059_tender_siae_count_updated.py +++ b/lemarche/tenders/migrations/0059_tender_siae_count_updated.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2023-10-19 09:18 +# Generated by Django 4.2.2 on 2023-10-25 11:48 from django.db import migrations, models @@ -18,4 +18,49 @@ class Migration(migrations.Migration): verbose_name="Nombre de structures concernées", ), ), + migrations.AddField( + model_name="tender", + name="siae_detail_contact_click_count", + field=models.IntegerField( + default=0, + help_text="Champ recalculé à intervalles réguliers", + verbose_name="Nombre de structures intéressées", + ), + ), + migrations.AddField( + model_name="tender", + name="siae_detail_display_count", + field=models.IntegerField( + default=0, + help_text="Champ recalculé à intervalles réguliers", + verbose_name="Nombre de structures vues", + ), + ), + migrations.AddField( + model_name="tender", + name="siae_email_link_click_count", + field=models.IntegerField( + default=0, + help_text="Champ recalculé à intervalles réguliers", + verbose_name="Nombre de structures cliquées", + ), + ), + migrations.AddField( + model_name="tender", + name="siae_email_link_click_or_detail_display_count", + field=models.IntegerField( + default=0, + help_text="Champ recalculé à intervalles réguliers", + verbose_name="Nombre de structures cliquées ou vues", + ), + ), + migrations.AddField( + model_name="tender", + name="siae_email_send_count", + field=models.IntegerField( + default=0, + help_text="Champ recalculé à intervalles réguliers", + verbose_name="Nombre de structures contactées", + ), + ), ] diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index a2a0ccc13..e280d4fec 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -398,6 +398,21 @@ class Tender(models.Model): siae_count = models.IntegerField( "Nombre de structures concernées", help_text="Champ recalculé à intervalles réguliers", default=0 ) + siae_email_send_count = models.IntegerField( + "Nombre de structures contactées", help_text="Champ recalculé à intervalles réguliers", default=0 + ) + siae_email_link_click_count = models.IntegerField( + "Nombre de structures cliquées", help_text="Champ recalculé à intervalles réguliers", default=0 + ) + siae_detail_display_count = models.IntegerField( + "Nombre de structures vues", help_text="Champ recalculé à intervalles réguliers", default=0 + ) + siae_email_link_click_or_detail_display_count = models.IntegerField( + "Nombre de structures cliquées ou vues", help_text="Champ recalculé à intervalles réguliers", default=0 + ) + siae_detail_contact_click_count = models.IntegerField( + "Nombre de structures intéressées", help_text="Champ recalculé à intervalles réguliers", default=0 + ) published_at = models.DateTimeField("Date de publication", blank=True, null=True) siae_list_last_seen_date = models.DateTimeField( "Date de dernière visite de l'auteur sur la page 'structures intéressées'", blank=True, null=True