Skip to content

Commit

Permalink
Merge pull request #716 from City-of-Helsinki/UHF-8535-forced-transla…
Browse files Browse the repository at this point in the history
…tions

UHF-8535: Forced translations
  • Loading branch information
jeremysteerio authored Jul 27, 2023
2 parents e01ee76 + 4daa16c commit 40e6682
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/js/job-search.min.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion src/js/react/apps/job-search/query/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ const alphabeticallySortTerms = {
},
};

const termSubAgg = {
unique: {
cardinality: {
field: `${IndexFields.RECRUITMENT_ID}.keyword`
}
}
};

// Base aggregations
export const AGGREGATIONS = {
aggs: {
Expand All @@ -28,29 +36,41 @@ export const AGGREGATIONS = {
field: 'task_area_external_id',
size: 100,
},
aggs: termSubAgg
},
employment: {
terms: {
field: 'employment_id',
size: 100,
},
aggs: termSubAgg
},
employment_type: {
terms: {
field: 'employment_type_id',
size: 100,
},
aggs: termSubAgg
},
employment_search_id: {
terms: {
field: 'employment_search_id',
size: 100,
},
aggs: termSubAgg
},
},
query: {
bool: {
filter: [languageFilter, nodeFilter],
filter: [nodeFilter],
// Legacy: filter out "forced" translations
must: [
{
term: {
[IndexFields.COPIED]: false,
},
},
],
},
},
};
Expand Down
15 changes: 14 additions & 1 deletion src/js/react/apps/job-search/store.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
import { atom } from 'jotai';

import CustomIds from './enum/CustomTermIds';
import bucketToMap from '@/react/common/helpers/Aggregations';
import { getLanguageLabel } from './helpers/Language';
import sortOptions from './helpers/Options';
import { AGGREGATIONS, EMPLOYMENT_FILTER_OPTIONS, LANGUAGE_OPTIONS, TASK_AREA_OPTIONS } from './query/queries';
import type OptionType from './types/OptionType';
import type Result from './types/Result';
import type Term from './types/Term';
import type URLParams from './types/URLParams';
import AggregationItem from './types/AggregationItem';

// Make maps out of bucket responses
const bucketToMap = (bucket: AggregationItem[]) => {
const result = new Map();

bucket.forEach(item => {
if (item?.unique?.value) {
result.set(item.key, item.unique.value);
}
});

return result;
};

const getParams = (searchParams: URLSearchParams) => {
const params: { [k: string]: any } = {};
Expand Down
9 changes: 9 additions & 0 deletions src/js/react/apps/job-search/types/AggregationItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { AggregationItem as CommonAggItem } from '@/types/Aggregation';

type AggregationItem = CommonAggItem & {
unique?: {
value: number;
}
};

export default AggregationItem;

0 comments on commit 40e6682

Please sign in to comment.