stricter subj name checking on question add, should log test fix

This commit is contained in:
mrfry 2023-03-07 19:43:55 +01:00
parent 537f4c413e
commit d962abfbc2
5 changed files with 144 additions and 51 deletions

View file

@ -499,16 +499,17 @@ function addQuestion(
logger.DebugLog(question, 'qdb add', 3)
const i = data.findIndex((subject) => {
return subj
.toLowerCase()
.includes(getSubjNameWithoutYear(subject.Name).toLowerCase())
return (
subj.toLowerCase() ===
getSubjNameWithoutYear(subject.Name).toLowerCase()
)
})
if (i !== -1) {
logger.DebugLog('Adding new question to existing subject', 'qdb add', 1)
data[i].Questions.push(question)
} else {
logger.DebugLog('Creating new subject for question', 'qdb add', 1)
logger.Log(`Creating new subject: ${subj}`)
data.push({
Name: subj,
Questions: [question],