Backend: Reduce code bloat
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
ef55fb0365
commit
8213eacde5
@ -18,14 +18,12 @@ const corpusUser = process.env.OWL_LDB_CORPUSUSER
|
|||||||
const corpusPass = process.env.OWL_LDB_CORPUSPASS
|
const corpusPass = process.env.OWL_LDB_CORPUSPASS
|
||||||
|
|
||||||
async function subset(allCorpus) {
|
async function subset(allCorpus) {
|
||||||
var cleanCorpus = await clean(allCorpus)
|
return (await clean(allCorpus))
|
||||||
return cleanCorpus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function get() {
|
async function get() {
|
||||||
var gzipData = await fetch()
|
var gzipData = await fetch()
|
||||||
var allCorpus = await extract(gzipData)
|
return (await extract(gzipData))
|
||||||
return allCorpus
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetch() {
|
async function fetch() {
|
||||||
@ -52,8 +50,7 @@ async function extract(input) {
|
|||||||
log.out(`corpus.extract: Extracting CORPUS archive`)
|
log.out(`corpus.extract: Extracting CORPUS archive`)
|
||||||
var raw = await gz.ungzip(input)
|
var raw = await gz.ungzip(input)
|
||||||
var obj = await JSON.parse(raw)
|
var obj = await JSON.parse(raw)
|
||||||
var output = obj.TIPLOCDATA
|
return (obj.TIPLOCDATA)
|
||||||
return output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function clean(input) {
|
async function clean(input) {
|
||||||
|
@ -26,11 +26,6 @@ async function dropCollection(coll){
|
|||||||
db.dropCollection(coll);
|
db.dropCollection(coll);
|
||||||
log.out(`DbAccess.dropCollection: dropped collection: '${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){
|
async function putCorpus(data){
|
||||||
@ -80,8 +75,7 @@ async function query(collection, query){
|
|||||||
var qcursor = qcoll.find(query)
|
var qcursor = qcoll.find(query)
|
||||||
qcursor.project({_id: 0})
|
qcursor.project({_id: 0})
|
||||||
log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`)
|
log.out(`dbAccess.query: Running Query: ${JSON.stringify(query)}`)
|
||||||
var qresult = await qcursor.toArray();
|
return (await qcursor.toArray());
|
||||||
return qresult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -18,10 +18,12 @@ const cacheFiles = [
|
|||||||
"/styles/boards.css",
|
"/styles/boards.css",
|
||||||
"/styles/find-code.css",
|
"/styles/find-code.css",
|
||||||
"/styles/help.css",
|
"/styles/help.css",
|
||||||
|
"/styles/issue.css",
|
||||||
"/styles/main.css",
|
"/styles/main.css",
|
||||||
"/styles/settings.css",
|
"/styles/settings.css",
|
||||||
"/js/find-code.js",
|
"/js/find-code.js",
|
||||||
"/js/index.js",
|
"/js/index.js",
|
||||||
|
"/js/issue.js",
|
||||||
"/js/lib.board.js",
|
"/js/lib.board.js",
|
||||||
"/js/lib.main.js",
|
"/js/lib.main.js",
|
||||||
"/js/settings.js",
|
"/js/settings.js",
|
||||||
|
Reference in New Issue
Block a user