Skip to content

Commit

Permalink
fix: Filter jobs based on job source attribute. (#786)
Browse files Browse the repository at this point in the history
Job in algolia either originate from course skills data or industry skills data. We want to ignore jobs that ignore from industry skills data at some places on the UI. This PR takes care of that.
  • Loading branch information
saleem-latif authored Aug 7, 2023
1 parent a322437 commit 8d8e46b
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/components/my-career/SearchJobRole.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import React, { useContext, useState } from 'react';
import PropTypes from 'prop-types';
import { getConfig } from '@edx/frontend-platform/config';
import { logError } from '@edx/frontend-platform/logging';
import { InstantSearch } from 'react-instantsearch-dom';
import { Configure, InstantSearch } from 'react-instantsearch-dom';
import { SearchContext, deleteRefinementAction } from '@edx/frontend-enterprise-catalog-search';
import { getAuthenticatedUser } from '@edx/frontend-platform/auth';
import FacetListRefinement from '@edx/frontend-enterprise-catalog-search/FacetListRefinement';
import { camelCaseObject } from '@edx/frontend-platform/utils';
import {
Button, Form, StatefulButton,
} from '@edx/paragon';
import { CURRENT_JOB_FACET } from '../skills-quiz/constants';
import { CURRENT_JOB_FACET, JOB_FILTERS } from '../skills-quiz/constants';
import { patchProfile, fetchJobDetailsFromAlgolia } from './data/service';
import { CURRENT_JOB_PROFILE_FIELD_NAME, SAVE_BUTTON_LABELS } from './data/constants';
import { useAlgoliaSearch } from '../../utils/hooks';
Expand Down Expand Up @@ -90,6 +90,10 @@ const SearchJobRole = (props) => {
searchClient={searchClient}
>
<p> Search for your job role </p>
<Configure
facetingAfterDistinct
filters={JOB_FILTERS.JOB_SOURCE_COURSE_SKILL}
/>
<FacetListRefinement
id="current-job-dropdown"
key={attribute}
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/data/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const useDefaultSearchFilters = ({
return getCatalogString(searchCatalogs);
}

// If the learner is not confined to certain catalogs, scope to all of the enterprise's catalogs
// If the learner is not confined to certain catalogs, scope to all of enterprise's catalogs
return `enterprise_customer_uuids:${enterpriseConfig.uuid}`;
},
[enterpriseConfig.uuid, searchCatalogs, showAllRefinement],
Expand Down
2 changes: 2 additions & 0 deletions src/components/skills-quiz/SearchJobCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { SearchContext } from '@edx/frontend-enterprise-catalog-search';
import { SkillsContext } from './SkillsContextProvider';
import { SET_KEY_VALUE } from './data/constants';
import JobCardComponent from './JobCardComponent';
import { JOB_FILTERS } from './constants';

const SearchJobCard = ({ index }) => {
const { refinements } = useContext(SearchContext);
Expand Down Expand Up @@ -37,6 +38,7 @@ const SearchJobCard = ({ index }) => {
async function fetchJobs() {
setIsLoading(true);
const { hits } = await index.search('', {
filters: JOB_FILTERS.JOB_SOURCE_COURSE_SKILL,
facetFilters: [
jobsToFetch,
],
Expand Down
7 changes: 6 additions & 1 deletion src/components/skills-quiz/SkillsQuizStepper.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
Button, Stepper, ModalDialog, Container, Form, Stack,
} from '@edx/paragon';
import algoliasearch from 'algoliasearch/lite';
import { InstantSearch } from 'react-instantsearch-dom';
import { Configure, InstantSearch } from 'react-instantsearch-dom';
import { getConfig } from '@edx/frontend-platform/config';
import { SearchContext } from '@edx/frontend-enterprise-catalog-search';
import { useHistory } from 'react-router-dom';
Expand Down Expand Up @@ -33,6 +33,7 @@ import {
STEP3,
SKILLS_QUIZ_SEARCH_PAGE_MESSAGE,
GOAL_DROPDOWN_DEFAULT_OPTION,
JOB_FILTERS,
} from './constants';
import { SkillsContext } from './SkillsContextProvider';
import { SET_KEY_VALUE } from './data/constants';
Expand Down Expand Up @@ -199,6 +200,10 @@ const SkillsQuizStepper = () => {
indexName={config.ALGOLIA_INDEX_NAME_JOBS}
searchClient={searchClient}
>
<Configure
facetingAfterDistinct
filters={JOB_FILTERS.JOB_SOURCE_COURSE_SKILL}
/>
<div className="mt-4.5">
Second, which industry describes where you work? (select one, or leave blank)
</div>
Expand Down
8 changes: 8 additions & 0 deletions src/components/skills-quiz/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,11 @@ export const HITS_PER_PAGE = 500;
export const LOADING_NO_OF_CARDS = 9;

export const JOB_DESCRIPTION_DISCLAIMER = 'This job description has been created by an artificial intelligence, and should be reviewed carefully.';

export const JOB_SOURCE_COURSE_SKILL = 'course_skill';
export const JOB_SOURCE_INDUSTRY = 'industry';

export const JOB_FILTERS = {
JOB_SOURCE_COURSE_SKILL: `job_sources:${JOB_SOURCE_COURSE_SKILL}`,
JOB_SOURCE_INDUSTRY: `job_sources:${JOB_SOURCE_INDUSTRY}`,
};

0 comments on commit 8d8e46b

Please sign in to comment.