Skip to content

Commit

Permalink
Add other count fields
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Oct 26, 2023
1 parent d432119 commit 011cfce
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]


Expand All @@ -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):
Expand All @@ -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)
Expand Down
47 changes: 46 additions & 1 deletion lemarche/tenders/migrations/0059_tender_siae_count_updated.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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",
),
),
]
15 changes: 15 additions & 0 deletions lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 011cfce

Please sign in to comment.