Skip to content

Commit

Permalink
(PC-34454)[API] feat: add publicationDate to Algolia serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
bpeyrou-pass committed Feb 7, 2025
1 parent 56a3828 commit 3132f25
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/src/pcapi/core/search/backends/algolia.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ def serialize_offer(cls, offer: offers_models.Offer, last_30_days_bookings: int)
"name": offer.name,
"nativeCategoryId": offer.subcategory.native_category_id,
"prices": sorted(prices),
"publicationDate": offer.publicationDate.isoformat() if offer.publicationDate else None,
"rankingWeight": offer.rankingWeight,
"releaseDate": release_date,
"bookFormat": extra_data.get("bookFormat"),
Expand Down
9 changes: 9 additions & 0 deletions api/tests/core/search/test_serialize_algolia.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,15 @@ def test_serialize_venue_with_one_bookable_offer():
assert serialized["has_at_least_one_bookable_offer"]


def test_serialize_future_offer():
offer = offers_factories.OfferFactory(isActive=False)
publication_date = datetime.datetime.utcnow() + datetime.timedelta(days=30)
offers_factories.FutureOfferFactory(offerId=offer.id, publicationDate=publication_date)

serialized = algolia.AlgoliaBackend().serialize_offer(offer, 0)
assert serialized["offer"]["publicationDate"] == publication_date.isoformat()


def test_serialize_collective_offer_template():
domain1 = educational_factories.EducationalDomainFactory(name="Danse")
domain2 = educational_factories.EducationalDomainFactory(name="Architecture")
Expand Down

0 comments on commit 3132f25

Please sign in to comment.