diff --git a/lemarche/tenders/admin.py b/lemarche/tenders/admin.py index 47fd3435f..1a0de7f86 100644 --- a/lemarche/tenders/admin.py +++ b/lemarche/tenders/admin.py @@ -313,7 +313,7 @@ class TenderAdmin(FieldsetsInlineMixin, admin.ModelAdmin): { "fields": ( "siae_ai_count_annotated_with_link", - "with_semantic_matching", + "with_ai_matching", ) }, ), diff --git a/lemarche/tenders/migrations/0070_tender_with_semantic_matching_and_more.py b/lemarche/tenders/migrations/0070_tender_with_ai_matching_tendersiae_found_with_ai_and_more.py similarity index 88% rename from lemarche/tenders/migrations/0070_tender_with_semantic_matching_and_more.py rename to lemarche/tenders/migrations/0070_tender_with_ai_matching_tendersiae_found_with_ai_and_more.py index df72f8f49..e343e0dab 100644 --- a/lemarche/tenders/migrations/0070_tender_with_semantic_matching_and_more.py +++ b/lemarche/tenders/migrations/0070_tender_with_ai_matching_tendersiae_found_with_ai_and_more.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.2 on 2024-01-16 13:38 +# Generated by Django 4.2.2 on 2024-01-29 14:18 from django.db import migrations, models @@ -11,7 +11,7 @@ class Migration(migrations.Migration): operations = [ migrations.AddField( model_name="tender", - name="with_semantic_matching", + name="with_ai_matching", field=models.BooleanField( default=False, help_text=( @@ -24,8 +24,8 @@ class Migration(migrations.Migration): ), migrations.AddField( model_name="tendersiae", - name="ai_had_found_it_too", - field=models.BooleanField(default=False, verbose_name="Trouvé aussi par l'IA"), + name="found_with_ai", + field=models.BooleanField(default=False, verbose_name="Trouvé par l'IA"), ), migrations.AlterField( model_name="tendersiae", diff --git a/lemarche/tenders/models.py b/lemarche/tenders/models.py index b994fc05a..7455cb55c 100644 --- a/lemarche/tenders/models.py +++ b/lemarche/tenders/models.py @@ -388,7 +388,7 @@ class Tender(models.Model): help_text="Retournera uniquement les structures qui ont comme périmètre d'intervention 'France entière'", default=False, ) - with_semantic_matching = models.BooleanField( + with_ai_matching = models.BooleanField( verbose_name="Activer le ciblage alternatif IA", help_text=( "Effectue une recherche sémantique avec la description du besoin pour ajouter des structures au ciblage " @@ -561,7 +561,7 @@ def set_siae_found_list(self): siae_found_list = Siae.objects.filter_with_tender(self) self.siaes.set(siae_found_list, clear=False) - if self.with_semantic_matching and self.validated_at is None: + if self.with_ai_matching and self.validated_at is None: if ( self.location and self.location.kind == Perimeter.KIND_CITY @@ -586,16 +586,14 @@ def set_siae_found_list(self): siae, through_defaults={ "source": tender_constants.TENDER_SIAE_SOURCE_AI, - "ai_had_found_it_too": True, + "found_with_ai": True, }, ) else: siaes_had_found_by_ia_too.append(siae) # keep the info that the AI also found those siaes - TenderSiae.objects.filter(tender_id=self.id, siae__in=siaes_had_found_by_ia_too).update( - ai_had_found_it_too=True - ) + TenderSiae.objects.filter(tender_id=self.id, siae__in=siaes_had_found_by_ia_too).update(found_with_ai=True) def save(self, *args, **kwargs): """ @@ -870,7 +868,7 @@ class TenderSiae(models.Model): choices=tender_constants.TENDER_SIAE_SOURCE_CHOICES, default=tender_constants.TENDER_SIAE_SOURCE_EMAIL, ) - ai_had_found_it_too = models.BooleanField("Trouvé aussi par l'IA", default=False) + found_with_ai = models.BooleanField("Trouvé par l'IA", default=False) # stats email_send_date = models.DateTimeField("Date d'envoi de l'e-mail", blank=True, null=True) diff --git a/lemarche/tenders/tests.py b/lemarche/tenders/tests.py index 171561ff1..2b942b4b1 100644 --- a/lemarche/tenders/tests.py +++ b/lemarche/tenders/tests.py @@ -222,7 +222,7 @@ def test_set_siae_found_list_with_semantic_search(self): presta_type=[siae_constants.PRESTA_BUILD], sectors=[self.sector], is_country_area=True, - with_semantic_matching=True, + with_ai_matching=True, validated_at=None, ) @@ -235,13 +235,13 @@ def test_set_siae_found_list_with_semantic_search(self): with self.subTest(siae=siae): self.assertIn(siae, tender.siaes.all()) - # test ai_had_found_it_too field value - self.assertEqual(TenderSiae.objects.get(tender=tender, siae=self.siae_one).ai_had_found_it_too, False) + # test found_with_ai field value + self.assertEqual(TenderSiae.objects.get(tender=tender, siae=self.siae_one).found_with_ai, False) tender_siae_two = TenderSiae.objects.get(tender=tender, siae=self.siae_two) - self.assertEqual(tender_siae_two.ai_had_found_it_too, True) + self.assertEqual(tender_siae_two.found_with_ai, True) for siae in [self.siae_two, self.siae_three, self.siae_four]: with self.subTest(siae=siae): - self.assertEqual(TenderSiae.objects.get(tender=tender, siae=siae).ai_had_found_it_too, True) + self.assertEqual(TenderSiae.objects.get(tender=tender, siae=siae).found_with_ai, True) # test source for siae in [self.siae_one, self.siae_two]: