Skip to content

Commit

Permalink
Changed threshold to be range slider
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnyTodgers committed Jul 13, 2023
1 parent 5fec148 commit b15b6f3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function App() {
const [fileInfos, setFileInfos] = useState([]);
const [existingInstruments, setExistingInstruments] = useState([]);
const [apiData, setApiData] = useState({});
const [resultsOptions, setResultsOptions] = useState({ threshold: 70, intraInstrument: false });
const [resultsOptions, setResultsOptions] = useState({ threshold: [70,100], intraInstrument: false });
const prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)');
const [mode, setMode] = useState();
const { storeHarmonisation } = useData();
Expand Down
2 changes: 1 addition & 1 deletion src/components/Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default function Results({ apiData, setApiData, setResultsOptions, result
return (apiData.instruments.map(instrument => {
return instrument.questions.map(q => {
return q.matches.reduce(function (a, e, i) {
if (Math.abs(e) >= (resultsOptions.threshold / 100) && (resultsOptions.intraInstrument || (i + 1 + q.question_index) > instrument.maxqidx))
if (Math.abs(e) >= (resultsOptions.threshold[0] / 100) && Math.abs(e) <= (resultsOptions.threshold[1] / 100) && (resultsOptions.intraInstrument || (i + 1 + q.question_index) > instrument.maxqidx))
a.push({ qi: q.question_index, mqi: i + 1 + q.question_index, match: e, ignore: ignoredMatches.includes(q.question_index + "-" + (i + 1 + q.question_index)) });
return a;
}, [])
Expand Down
4 changes: 2 additions & 2 deletions src/components/ResultsOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export default function ResultsOptions({ resultsOptions, setResultsOptions, make
</Typography></div>
<Slider
value={threshold}
min={30}
min={0}
valueLabelDisplay="auto"
onChange={(e, value) => {
setThreshold(value);
}}
onChangeCommitted={(e, value) => {
let thisOptions = { ...resultsOptions };
thisOptions.threshold = isNaN(value) ? 70 : value;
thisOptions.threshold = value;
setResultsOptions(thisOptions)
}}
/>
Expand Down

0 comments on commit b15b6f3

Please sign in to comment.