mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Removed some old utils, added readme to utils, some new test data
This commit is contained in:
parent
6e83e5051c
commit
105d1ee8be
9 changed files with 333 additions and 735 deletions
|
@ -19,13 +19,11 @@ Question Server
|
|||
|
||||
module.exports = {
|
||||
ProcessIncomingRequest: ProcessIncomingRequest,
|
||||
LoadJSON: LoadJSON,
|
||||
ProcessQA: ProcessQA
|
||||
LoadJSON: LoadJSON
|
||||
}
|
||||
|
||||
const dataFile = './public/data.json'
|
||||
const recDataFile = './stats/recdata'
|
||||
const qaFile = './public/qa'
|
||||
|
||||
const logger = require('../utils/logger.js')
|
||||
const idStats = require('../utils/ids.js')
|
||||
|
@ -163,26 +161,3 @@ function LoadJSON (dataFile) {
|
|||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
function ProcessQA () {
|
||||
if (!utils.FileExists(qaFile)) { utils.WriteFile('', qaFile) }
|
||||
|
||||
let a = utils.ReadFile(qaFile).split('\n')
|
||||
let r = []
|
||||
let ind = 0
|
||||
for (let i = 0; i < a.length; i++) {
|
||||
if (a[i] === '#') { ind++ } else {
|
||||
if (r[ind] === undefined) { r[ind] = {} }
|
||||
|
||||
if (r[ind].q === undefined) {
|
||||
r[ind].q = a[i]
|
||||
} else {
|
||||
if (r[ind].a === undefined) { r[ind].a = [] }
|
||||
|
||||
r[ind].a.push(a[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue