Skip to content

Commit 8fdeb82

Browse files
authored
feat: filter secondary school courses HH-460 (#993)
* feat: filter secondary school courses Refs: HH-460
1 parent 3b0b207 commit 8fdeb82

4 files changed

Lines changed: 40 additions & 2 deletions

File tree

apps/hobbies-helsinki/src/domain/event/__tests__/EventPageContainer.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from '../../../../config/vitest/test-utils';
3535

3636
import AppConfig from '../../app/AppConfig';
37+
import { HOBBIES_EXCLUDED_KEYWORDS } from '../../search/eventSearch/constants';
3738
import type { EventPageContainerProps } from '../EventPageContainer';
3839
import EventPageContainer from '../EventPageContainer';
3940

@@ -244,6 +245,7 @@ it('shows similar events when SIMILAR_EVENTS flag is on', async () => {
244245
audienceMinAgeLt: '5',
245246
audienceMaxAgeGt: '15',
246247
keywordOrSet2: ['yso:p916'],
248+
keywordNot: HOBBIES_EXCLUDED_KEYWORDS,
247249
language: undefined,
248250
pageSize: 100,
249251
publisherAncestor: null,

apps/hobbies-helsinki/src/domain/search/eventSearch/__tests__/utils.test.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import {
55
} from '@events-helsinki/components';
66
import { advanceTo, clear } from 'jest-date-mock';
77

8-
import { COURSE_DEFAULT_SEARCH_FILTERS } from '../constants';
8+
import {
9+
COURSE_DEFAULT_SEARCH_FILTERS,
10+
HOBBIES_EXCLUDED_KEYWORDS,
11+
} from '../constants';
912
import {
1013
clampAgeInput,
1114
getEventSearchVariables,
@@ -141,6 +144,29 @@ describe('getEventSearchVariables function', () => {
141144
expect(start7).toBe('now');
142145
expect(end7).toBe('2020-10-15');
143146
});
147+
148+
it('should always include HOBBIES_EXCLUDED_KEYWORDS in keywordNot', () => {
149+
const { keywordNot } = getEventSearchVariables({
150+
...defaultParams,
151+
params: new URLSearchParams(),
152+
});
153+
expect(keywordNot).toStrictEqual(
154+
expect.arrayContaining(HOBBIES_EXCLUDED_KEYWORDS)
155+
);
156+
});
157+
158+
it('should merge user-provided keywordNot with HOBBIES_EXCLUDED_KEYWORDS', () => {
159+
const userKeyword = 'yso:p1234';
160+
const { keywordNot } = getEventSearchVariables({
161+
...defaultParams,
162+
params: new URLSearchParams(
163+
`?${EVENT_SEARCH_FILTERS.KEYWORD_NOT}=${userKeyword}`
164+
),
165+
});
166+
expect(keywordNot).toStrictEqual(
167+
expect.arrayContaining([userKeyword, ...HOBBIES_EXCLUDED_KEYWORDS])
168+
);
169+
});
144170
});
145171

146172
describe('getNextPage function', () => {

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ export const CATEGORY_CATALOG = {
9494
},
9595
};
9696

97+
/**
98+
* Keywords that are always excluded from hobbies search results,
99+
* regardless of user-provided filters.
100+
*/
101+
export const HOBBIES_EXCLUDED_KEYWORDS = [
102+
// Secondary school cross-institutional studies are not hobbies
103+
'helsinki:secondary_schools_cross_institutional_studies',
104+
];
105+
97106
export const MOVIES_AND_MEDIA_COURSES_KEYWORDS = [
98107
'yso:p1235', // elokuva
99108
'kulke:29', // elokuvat

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import type { COURSE_CATEGORIES } from './constants';
3636
import {
3737
COURSE_DEFAULT_SEARCH_FILTERS,
3838
courseCategories,
39+
HOBBIES_EXCLUDED_KEYWORDS,
3940
MAPPED_PLACES,
4041
CATEGORY_CATALOG,
4142
MAPPED_COURSE_CATEGORIES,
@@ -275,7 +276,7 @@ export const getEventSearchVariables = ({
275276
// internetBased: onlyRemoteEvents || undefined,
276277
keywordOrSet2: [...(keyword ?? []), ...mappedCategories],
277278
keywordAnd,
278-
keywordNot,
279+
keywordNot: [...(keywordNot ?? []), ...HOBBIES_EXCLUDED_KEYWORDS],
279280
language,
280281
location: places.sort((a, b) => a.localeCompare(b)),
281282
pageSize,

0 commit comments

Comments
 (0)