Skip to content

Commit

Permalink
Fixed off-by-one error when processing matches - the simplified API o…
Browse files Browse the repository at this point in the history
…bject only stores matches starting at the question AFTER the current
  • Loading branch information
ronnyTodgers committed Jul 5, 2023
1 parent 129bd4b commit c3e552e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ function App() {
return instrument.questions.map(q=>{
return q.matches.reduce(function (a, e, i) {
if (Math.abs(e) >= (resultsOptions.threshold/100) &&
(resultsOptions.intraInstrument || (i+q.question_index) > instrument.maxqidx )) {
var mq = getQuestion(i+q.question_index);
var mi = getInstrument(i+q.question_index);
(resultsOptions.intraInstrument || (i + 1 + q.question_index) > instrument.maxqidx )) {
var mq = getQuestion(i + 1 + q.question_index);
var mi = getInstrument(i + 1 +q.question_index);
a.push(
{
instrument1: instrument.name,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Results.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default function Results({ apiData, setApiData, setResultsOptions, result
return (apiData.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 + q.question_index) > instrument.maxqidx))
a.push({ qi: q.question_index, mqi: i + q.question_index, match: e });
if (Math.abs(e) >= (resultsOptions.threshold / 100) && (resultsOptions.intraInstrument || (i + 1 + q.question_index) > instrument.maxqidx))
a.push({ qi: q.question_index, mqi: i + 1 + q.question_index, match: e });
return a;
}, [])
}).flat();
Expand Down

0 comments on commit c3e552e

Please sign in to comment.