mirror of
https://github.com/lucaspalomodevelop/eventcally.git
synced 2026-03-13 00:07:22 +00:00
Advanced keyword filter #536
This commit is contained in:
parent
a8149fa6b2
commit
e4d04d28d4
@ -69,9 +69,16 @@ def fill_event_filter(event_filter, params: EventSearchParams):
|
|||||||
|
|
||||||
if params.keyword:
|
if params.keyword:
|
||||||
tq = func.websearch_to_tsquery("german", params.keyword)
|
tq = func.websearch_to_tsquery("german", params.keyword)
|
||||||
|
like_keyword = "%" + params.keyword + "%"
|
||||||
event_filter = and_(
|
event_filter = and_(
|
||||||
event_filter,
|
event_filter,
|
||||||
Event.__ts_vector__.op("@@")(tq),
|
or_(
|
||||||
|
Event.__ts_vector__.op("@@")(tq),
|
||||||
|
Event.name.ilike(like_keyword),
|
||||||
|
EventPlace.name.ilike(like_keyword),
|
||||||
|
Location.city.ilike(like_keyword),
|
||||||
|
EventOrganizer.name.ilike(like_keyword),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
if params.category_id:
|
if params.category_id:
|
||||||
@ -250,6 +257,7 @@ def get_event_dates_query(params: EventSearchParams):
|
|||||||
.join(Event.admin_unit)
|
.join(Event.admin_unit)
|
||||||
.join(Event.event_place, isouter=True)
|
.join(Event.event_place, isouter=True)
|
||||||
.join(EventPlace.location, isouter=True)
|
.join(EventPlace.location, isouter=True)
|
||||||
|
.join(Event.organizer, isouter=True)
|
||||||
)
|
)
|
||||||
|
|
||||||
if admin_unit_reference:
|
if admin_unit_reference:
|
||||||
@ -268,7 +276,7 @@ def get_event_dates_query(params: EventSearchParams):
|
|||||||
.joinedload(Event.categories)
|
.joinedload(Event.categories)
|
||||||
.load_only(EventCategory.id, EventCategory.name),
|
.load_only(EventCategory.id, EventCategory.name),
|
||||||
joinedload(EventDate.event)
|
joinedload(EventDate.event)
|
||||||
.joinedload(Event.organizer)
|
.contains_eager(Event.organizer)
|
||||||
.load_only(EventOrganizer.id, EventOrganizer.name),
|
.load_only(EventOrganizer.id, EventOrganizer.name),
|
||||||
joinedload(EventDate.event).joinedload(Event.photo).load_only(Image.id),
|
joinedload(EventDate.event).joinedload(Event.photo).load_only(Image.id),
|
||||||
joinedload(EventDate.event)
|
joinedload(EventDate.event)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user