Backend: Reduce code bloat

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-01-31 00:18:07 +00:00
parent ef55fb0365
commit 8213eacde5
3 changed files with 6 additions and 13 deletions

View File

@ -18,14 +18,12 @@ const corpusUser = process.env.OWL_LDB_CORPUSUSER
const corpusPass = process.env.OWL_LDB_CORPUSPASS
async function subset(allCorpus) {
var cleanCorpus = await clean(allCorpus)
return cleanCorpus
return (await clean(allCorpus))
}
async function get() {
var gzipData = await fetch()
var allCorpus = await extract(gzipData)
return allCorpus
return (await extract(gzipData))
}
async function fetch() {
@ -52,8 +50,7 @@ async function extract(input) {
log.out(`corpus.extract: Extracting CORPUS archive`)
var raw = await gz.ungzip(input)
var obj = await JSON.parse(raw)
var output = obj.TIPLOCDATA
return output
return (obj.TIPLOCDATA)
}
async function clean(input) {

View File

@ -26,11 +26,6 @@ async function dropCollection(coll){
db.dropCollection(coll);
log.out(`DbAccess.dropCollection: dropped collection: '${coll}'`)
}
// ALTERNATIVE METHOD - Appears to not be needed:
// This code returns and prints an array containing an object for each existing collection.
// var cols = await db.listCollections().toArray()
// log.out(`dbAccess.dropCollection: Existing collections: ${JSON.stringify(cols)}`)
// If (any object in the Array contains name:{coll} then exsists. If not doesn't exist.)
}
async function putCorpus(data){
@ -80,8 +75,7 @@ async function query(collection, query){
var qcursor = qcoll.find(query)
qcursor.project({_id: 0})
log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`)
var qresult = await qcursor.toArray();
return qresult;
return (await qcursor.toArray());
}
module.exports = {

View File

@ -18,10 +18,12 @@ const cacheFiles = [
"/styles/boards.css",
"/styles/find-code.css",
"/styles/help.css",
"/styles/issue.css",
"/styles/main.css",
"/styles/settings.css",
"/js/find-code.js",
"/js/index.js",
"/js/issue.js",
"/js/lib.board.js",
"/js/lib.main.js",
"/js/settings.js",