Skip to content

Commit b1cfa86

Browse files
committed
fix(search): filter event search with division
TH-1429. NOTE: This affects in every apps searches: - event / course search - similar events - upcoming events The event search result list should not contain events outside the city of Helsinki. This commit fixes the event list search variables to contain a city of Helsinki division filter. The `*Ongoing*` -queries in LinkedEvents are using a search index (cache) that stores only the city of Helsinki events, but when the *Ongoing* -filter is not in use, the result set will contain also events outside the city of Helsinki. When the `allOngoingAnd` text query filter was replaced with a newer `xFullText` filter, the result set was no longer limited to city of Helsinki events (by the search index). To fix that, a new division filter is taken in action. NOTE: This should not be mixed with the `helsinkiOnly` -filter, that is still active in code base (but might be hidden in UI). The `helsinkiOnly` filter currently limits the result set by filtering it with `publisherAnchestor` field value (ahjo:00001; Helsinki; @see https://api.hel.fi/linkedevents/v1/organization/ahjo:00001/).
1 parent 23c095b commit b1cfa86

24 files changed

Lines changed: 138 additions & 100 deletions

File tree

apps/events-helsinki/config/vitest/mocks/eventListMocks.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
EventTypeId,
1313
DEFAULT_EVENT_SORT_OPTION,
1414
EVENT_SEARCH_FILTERS,
15+
HELSINKI_OCD_DIVISION_ID,
1516
} from '@events-helsinki/components';
1617
import AppConfig from '../../../src/domain/app/AppConfig';
1718

@@ -27,6 +28,8 @@ export const baseVariables = {
2728
sort: DEFAULT_EVENT_SORT_OPTION,
2829
start: 'now',
2930
startsAfter: undefined,
31+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
32+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
3033
// Removed to experiment LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512).
3134
// superEventType: ['umbrella', 'none'],
3235
[EVENT_SEARCH_FILTERS.ONGOING]: true,

apps/events-helsinki/src/domain/event/useSimilarEventsQueryVariables.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {
22
EVENT_SEARCH_FILTERS,
33
EVENT_SORT_OPTIONS,
4-
} from '@events-helsinki/components/constants/event-constants';
4+
HELSINKI_OCD_DIVISION_ID,
5+
} from '@events-helsinki/components';
56
import type { EventFields } from '@events-helsinki/components/types/event-types';
67
import React from 'react';
78

@@ -32,6 +33,10 @@ const useSimilarEventsQueryVariables = (event: EventFields) => {
3233
pageSize: 100,
3334
params: new URLSearchParams(searchParams),
3435
sortOrder: EVENT_SORT_OPTIONS.END_TIME,
36+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
37+
// NOTE: This is not needed if using any `*Ongoing` -filter as
38+
// they automatically limit the results to city of Helsinki events.
39+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
3540
// Don't use superEventType when experimenting:
3641
// LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512)
3742
// superEventType: ['umbrella', 'none']

apps/events-helsinki/src/domain/search/eventSearch/SearchPage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import {
1414
isEventSortOption,
1515
EventList,
1616
useClearClosedEventsFromApolloCache,
17+
HELSINKI_OCD_DIVISION_ID,
18+
EVENT_SEARCH_FILTERS,
1719
} from '@events-helsinki/components';
1820
import { useRouter } from 'next/router';
1921
import queryString from 'query-string';
@@ -45,6 +47,10 @@ const useSearchQuery = () => {
4547
sortOrder: isEventSortOption(sortParam)
4648
? sortParam
4749
: DEFAULT_EVENT_SORT_OPTION,
50+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
51+
// NOTE: This is not needed if using any `*Ongoing` -filter as
52+
// they automatically limit the results to city of Helsinki events.
53+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
4854
// Don't use superEventType when experimenting
4955
// LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512)
5056
// superEventType: ['umbrella', 'none']

apps/events-helsinki/src/domain/search/eventSearch/utils.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export const getEventSearchVariables = ({
141141
superEventType,
142142
superEvent,
143143
place,
144+
division,
144145
}: {
145146
include: string[];
146147
language?: AppLanguage;
@@ -150,6 +151,7 @@ export const getEventSearchVariables = ({
150151
superEventType?: string[];
151152
superEvent?: string;
152153
place?: string;
154+
division?: string[];
153155
}): QueryEventListArgs => {
154156
const {
155157
categories,
@@ -212,6 +214,7 @@ export const getEventSearchVariables = ({
212214
return {
213215
[EVENT_SEARCH_FILTERS.TEXT]: !isEmpty(text) ? text?.join(',') : undefined, // NOTE: only *OngoingAnd supports Array.
214216
[EVENT_SEARCH_FILTERS.ONGOING]: true,
217+
[EVENT_SEARCH_FILTERS.DIVISIONS]: division,
215218
end,
216219
include,
217220
publisherAncestor,

apps/hobbies-helsinki/config/vitest/mocks/eventListMocks.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
EVENT_SEARCH_FILTERS,
1212
EventListDocument,
1313
EventTypeId,
14+
HELSINKI_OCD_DIVISION_ID,
1415
} from '@events-helsinki/components';
1516
import AppConfig from '../../../src/domain/app/AppConfig';
1617

@@ -29,6 +30,8 @@ export const baseVariables = {
2930
sort: 'end_time',
3031
start: 'now',
3132
startsAfter: undefined,
33+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
34+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
3235
// Removed to experiment:
3336
// LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512).
3437
// superEventType: ['umbrella', 'none'],

apps/hobbies-helsinki/src/domain/event/useSimilarEventsQueryVariables.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import {
22
EVENT_SEARCH_FILTERS,
33
EVENT_SORT_OPTIONS,
4-
} from '@events-helsinki/components/constants/event-constants';
5-
import type { EventFields } from '@events-helsinki/components/types/event-types';
4+
HELSINKI_OCD_DIVISION_ID,
5+
} from '@events-helsinki/components';
6+
import type { EventFields } from '@events-helsinki/components';
67
import React from 'react';
78
import {
89
getEventCategories,
@@ -34,6 +35,8 @@ const useSimilarEventsQueryVariables = (event: EventFields) => {
3435
pageSize: 100,
3536
params: new URLSearchParams(searchParams),
3637
sortOrder: EVENT_SORT_OPTIONS.END_TIME,
38+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
39+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
3740
// Don't use superEventType when experimenting:
3841
// LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512)
3942
// superEventType: ['umbrella', 'none']

apps/hobbies-helsinki/src/domain/search/eventSearch/SearchPage.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
EVENT_SORT_OPTIONS,
1313
EventList,
1414
useClearClosedEventsFromApolloCache,
15+
HELSINKI_OCD_DIVISION_ID,
16+
EVENT_SEARCH_FILTERS,
1517
} from '@events-helsinki/components';
1618
import { useRouter } from 'next/router';
1719
import queryString from 'query-string';
@@ -41,6 +43,10 @@ const useSearchQuery = () => {
4143
params: searchParams,
4244
place: params.place,
4345
sortOrder: EVENT_SORT_OPTIONS.END_TIME,
46+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
47+
// NOTE: This is not needed if using any `*Ongoing` -filter as
48+
// they automatically limit the results to city of Helsinki events.
49+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
4450
// Don't use superEventType when experimenting:
4551
// LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512)
4652
// superEventType: ['umbrella', 'none']

apps/hobbies-helsinki/src/domain/search/eventSearch/utils.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export const getEventSearchVariables = ({
181181
superEventType,
182182
superEvent,
183183
place,
184+
division,
184185
}: {
185186
include: string[];
186187
language?: AppLanguage;
@@ -190,6 +191,7 @@ export const getEventSearchVariables = ({
190191
superEventType?: string[];
191192
superEvent?: string;
192193
place?: string;
194+
division?: string[];
193195
}): QueryEventListArgs => {
194196
const {
195197
categories,
@@ -259,6 +261,7 @@ export const getEventSearchVariables = ({
259261
return {
260262
[EVENT_SEARCH_FILTERS.TEXT]: !isEmpty(text) ? text?.join(',') : undefined, // NOTE: only *OngoingAnd supports Array.
261263
[EVENT_SEARCH_FILTERS.ONGOING]: true,
264+
[EVENT_SEARCH_FILTERS.DIVISIONS]: division,
262265
end,
263266
include,
264267
publisherAncestor,

apps/sports-helsinki/config/vitest/mocks/eventListMocks.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import type {
77
EventType,
88
QueryEventListArgs,
99
} from '@events-helsinki/components';
10-
import { EventListDocument, EventTypeId } from '@events-helsinki/components';
10+
import {
11+
EVENT_SEARCH_FILTERS,
12+
EventListDocument,
13+
EventTypeId,
14+
HELSINKI_OCD_DIVISION_ID,
15+
} from '@events-helsinki/components';
1116

1217
export const baseVariables = {
1318
end: '',
@@ -21,6 +26,8 @@ export const baseVariables = {
2126
publisherAncestor: null,
2227
sort: 'end_time',
2328
start: 'now',
29+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
30+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
2431
// Removed to experiment LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512).
2532
// superEventType: ['umbrella', 'none'],
2633
};

apps/sports-helsinki/src/domain/event/useSimilarEventsQueryVariables.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
import { EVENT_SORT_OPTIONS } from '@events-helsinki/components/constants/event-constants';
2-
import { EventTypeId } from '@events-helsinki/components/types';
1+
import {
2+
EVENT_SORT_OPTIONS,
3+
EventTypeId,
4+
HELSINKI_OCD_DIVISION_ID,
5+
} from '@events-helsinki/components';
36
import type { EventFields } from '@events-helsinki/components/types/event-types';
47
import React from 'react';
58
import { EVENT_SEARCH_FILTERS } from '../search/eventSearch/constants';
@@ -31,6 +34,8 @@ const useSimilarEventsQueryVariables = (event: EventFields) => {
3134
pageSize: 100,
3235
params: new URLSearchParams(searchParams),
3336
sortOrder: EVENT_SORT_OPTIONS.END_TIME,
37+
// Always filter with HELSINKI_OCD_DIVISION_ID to limit the results to city of Helsinki events.
38+
[EVENT_SEARCH_FILTERS.DIVISIONS]: [HELSINKI_OCD_DIVISION_ID],
3439
// Don't use superEventType when experimenting:
3540
// LIIKUNTA-512 (https://helsinkisolutionoffice.atlassian.net/browse/LIIKUNTA-512)
3641
// superEventType: ['umbrella', 'none']

0 commit comments

Comments
 (0)