Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PC-29215)[API] feat: split films, series, cinema search group #13956

Merged
merged 3 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 31 additions & 22 deletions api/src/pcapi/core/categories/subcategories_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ def __init__(
technical_name: str | None = None,
gtls: list[str] | None = None,
position: int | None = None,
search_filter: str | None = None,
) -> None:
self.id = technical_name or str(uuid.uuid4())
self.label = label
self.gtls = gtls
self.parents = parents or []
self.position = position
self.search_filter = search_filter

@property
def search_value(self) -> str | None:
Expand Down Expand Up @@ -192,17 +190,17 @@ def get_show_nodes() -> list[ShowGenre]:
SEARCH_GROUP_ARTS_LOISIRS_CREATIFS = SearchGroup(
technical_name="ARTS_LOISIRS_CREATIFS",
label="Arts & loisirs créatifs",
position=5,
position=6,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ question: par curiosité, comment on choisit la valeur de position ?
low logaf‏

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est les UX qui décident.
L'ancien search group était en 2, et on veut mettre les deux qui le remplacent au même endroit, donc positions 2 et 3, donc ça décale le reste de 1.
Pour vérifier qu'on fait pas de bêtise, c'est bien de tester en local et de comparer à la prod.
Je pourrai rajouter un screenshot, mais l'app ne prend pas encore en compte ces données-là (WIP).

)
SEARCH_GROUP_CARTES_JEUNES = SearchGroup(
technical_name="CARTES_JEUNES",
label="Cartes jeunes",
position=11,
position=12,
)
SEARCH_GROUP_CD_VINYLE_MUSIQUE_EN_LIGNE = SearchGroup(
technical_name="CD_VINYLE_MUSIQUE_EN_LIGNE",
label="CD, vinyles, musique en ligne",
position=4,
position=5,
)
SEARCH_GROUP_CONCERTS_FESTIVALS = SearchGroup(
technical_name="CONCERTS_FESTIVALS",
Expand All @@ -212,17 +210,27 @@ def get_show_nodes() -> list[ShowGenre]:
SEARCH_GROUP_EVENEMENTS_EN_LIGNE = SearchGroup(
technical_name="EVENEMENTS_EN_LIGNE",
label="Évènements en ligne",
position=12,
position=14,
)
SEARCH_GROUP_FILMS_SERIES_CINEMA = SearchGroup(
technical_name="FILMS_SERIES_CINEMA",
label="Cinéma, films et séries",
position=13,
position=2,
)
SEARCH_GROUP_CINEMA = SearchGroup(
technical_name="CINEMA",
label="Cinéma",
position=2,
)
SEARCH_GROUP_FILMS_DOCUMENTAIRES_SERIES = SearchGroup(
technical_name="FILMS_DOCUMENTAIRES_SERIES",
label="Films, documentaires et séries",
position=3,
)
SEARCH_GROUP_INSTRUMENTS = SearchGroup(
technical_name="INSTRUMENTS",
label="Instruments de musique",
position=2,
position=10,
)
SEARCH_GROUP_JEUX_JEUX_VIDEOS = SearchGroup(
technical_name="JEUX_JEUX_VIDEOS",
Expand All @@ -232,17 +240,17 @@ def get_show_nodes() -> list[ShowGenre]:
SEARCH_GROUP_LIVRES = SearchGroup(
technical_name="LIVRES",
label="Livres",
position=8,
position=4,
)
SEARCH_GROUP_MEDIA_PRESSE = SearchGroup(
technical_name="MEDIA_PRESSE",
label="Médias & presse",
position=3,
position=11,
)
SEARCH_GROUP_MUSEES_VISITES_CULTURELLES = SearchGroup(
technical_name="MUSEES_VISITES_CULTURELLES",
label="Musées & visites culturelles",
position=10,
position=8,
)
SEARCH_GROUP_NONE = SearchGroup(
technical_name="NONE",
Expand All @@ -252,12 +260,12 @@ def get_show_nodes() -> list[ShowGenre]:
SEARCH_GROUP_RENCONTRES_CONFERENCES = SearchGroup(
technical_name="RENCONTRES_CONFERENCES",
label="Conférences & rencontres",
position=7,
position=13,
)
SEARCH_GROUP_SPECTACLES = SearchGroup(
technical_name="SPECTACLES",
label="Spectacles",
position=6,
position=7,
)
# endregion

Expand Down Expand Up @@ -295,7 +303,7 @@ def get_show_nodes() -> list[ShowGenre]:
NATIVE_CATEGORY_CARTES_CINEMA = NativeCategory(
technical_name="CARTES_CINEMA",
label="Cartes cinéma",
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id],
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_CINEMA.id],
)
NATIVE_CATEGORY_CD = NativeCategory(
technical_name="CD",
Expand Down Expand Up @@ -330,7 +338,7 @@ def get_show_nodes() -> list[ShowGenre]:
NATIVE_CATEGORY_DVD_BLU_RAY = NativeCategory(
technical_name="DVD_BLU_RAY",
label="DVD, Blu-Ray",
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id],
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_FILMS_DOCUMENTAIRES_SERIES.id],
)
NATIVE_CATEGORY_ESCAPE_GAMES = NativeCategory(
technical_name="ESCAPE_GAMES",
Expand All @@ -340,7 +348,7 @@ def get_show_nodes() -> list[ShowGenre]:
NATIVE_CATEGORY_EVENEMENTS_CINEMA = NativeCategory(
technical_name="EVENEMENTS_CINEMA",
label="Evènements cinéma",
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id],
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_CINEMA.id],
)
NATIVE_CATEGORY_EVENEMENTS_PATRIMOINE = NativeCategory(
technical_name="EVENEMENTS_PATRIMOINE",
Expand All @@ -360,7 +368,7 @@ def get_show_nodes() -> list[ShowGenre]:
NATIVE_CATEGORY_FILMS_SERIES_EN_LIGNE = NativeCategory(
technical_name="FILMS_SERIES_EN_LIGNE",
label="Films, séries en ligne",
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id],
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_FILMS_DOCUMENTAIRES_SERIES.id],
)
NATIVE_CATEGORY_JEUX_EN_LIGNE = NativeCategory(
technical_name="JEUX_EN_LIGNE",
Expand Down Expand Up @@ -402,6 +410,7 @@ def get_show_nodes() -> list[ShowGenre]:
label="Musique en ligne",
parents=[SEARCH_GROUP_CD_VINYLE_MUSIQUE_EN_LIGNE.id],
)
NATIVE_CATEGORY_NONE = NativeCategory(technical_name="NATIVE_CATEGORY_NONE", label="None", parents=[])
NATIVE_CATEGORY_PARTITIONS_DE_MUSIQUE = NativeCategory(
technical_name="PARTITIONS_DE_MUSIQUE",
label="Partitions de musique",
Expand Down Expand Up @@ -456,7 +465,7 @@ def get_show_nodes() -> list[ShowGenre]:
NATIVE_CATEGORY_SEANCES_DE_CINEMA = NativeCategory(
technical_name="SEANCES_DE_CINEMA",
label="Séances de cinéma",
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id],
parents=[SEARCH_GROUP_FILMS_SERIES_CINEMA.id, SEARCH_GROUP_CINEMA.id],
)
NATIVE_CATEGORY_SPECTACLES_ENREGISTRES = NativeCategory(
technical_name="SPECTACLES_ENREGISTRES",
Expand Down Expand Up @@ -609,7 +618,7 @@ class EacFormat(Enum):
class Subcategory:
id: str
category: categories.Category
native_category: NativeCategory | None
native_category: NativeCategory
pro_label: str
app_label: str
search_group_name: str
Expand Down Expand Up @@ -647,8 +656,8 @@ def category_id(self) -> str:
return self.category.id

@property
def native_category_id(self) -> str | None:
return self.native_category.id if self.native_category else None
def native_category_id(self) -> str:
return self.native_category.id

@property
def is_offline_only(self) -> bool:
Expand Down Expand Up @@ -1294,7 +1303,7 @@ def is_online_only(self) -> bool:
CARTE_JEUNES = Subcategory(
id="CARTE_JEUNES",
category=categories.CARTE_JEUNES,
native_category=None,
native_category=NATIVE_CATEGORY_NONE,
pro_label="Carte jeunes",
app_label="Carte jeunes",
search_group_name=SEARCH_GROUP_CARTES_JEUNES.id,
Expand Down
3 changes: 2 additions & 1 deletion api/src/pcapi/core/search/backends/algolia.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from pcapi import settings
from pcapi.core.categories import categories
from pcapi.core.categories import subcategories_v2
from pcapi.core.educational.academies import get_academy_from_department
import pcapi.core.educational.api.offer as educational_api_offer
import pcapi.core.educational.models as educational_models
Expand Down Expand Up @@ -526,7 +527,7 @@ def serialize_offer(cls, offer: offers_models.Offer, last_30_days_bookings: int)

search_groups = (
offer.subcategory.native_category.parents
if offer.subcategory.native_category
if offer.subcategory.native_category != subcategories_v2.NATIVE_CATEGORY_NONE
else [offer.subcategory.search_group_name]
)

Expand Down
3 changes: 3 additions & 0 deletions api/tests/routes/native/openapi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,6 +1094,7 @@ def test_public_api(client):
"LUDOTHEQUE",
"MATERIELS_CREATIFS",
"MUSIQUE_EN_LIGNE",
"NATIVE_CATEGORY_NONE",
"PARTITIONS_DE_MUSIQUE",
"PODCAST",
"PRATIQUES_ET_ATELIERS_ARTISTIQUES",
Expand Down Expand Up @@ -1756,6 +1757,8 @@ def test_public_api(client):
"CONCERTS_FESTIVALS",
"EVENEMENTS_EN_LIGNE",
"FILMS_SERIES_CINEMA",
"CINEMA",
"FILMS_DOCUMENTAIRES_SERIES",
"INSTRUMENTS",
"JEUX_JEUX_VIDEOS",
"LIVRES",
Expand Down
2 changes: 1 addition & 1 deletion api/tests/routes/native/v1/offers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2339,7 +2339,7 @@ def test_get_subcategories_v2(self, client):
assert found_subcategory_ids == expected_subcategory_ids

found_search_group_names = {x["name"] for x in response.json["searchGroups"]}
expected_search_group_names = {x.search_group_name for x in subcategories.ALL_SUBCATEGORIES}
expected_search_group_names = {x.name for x in subcategories.SEARCH_GROUPS}
assert found_search_group_names == expected_search_group_names

found_home_labels = {x["name"] for x in response.json["homepageLabels"]}
Expand Down
Loading