style(previews): fix eslint for preview service
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Viewer, Converter } from '@speckle/viewer'
|
||||
import { Viewer } from '@speckle/viewer'
|
||||
|
||||
let v = new Viewer({ container: document.getElementById('renderer'), showStats: false })
|
||||
// v.on( 'load-progress', args => console.log( args ) )
|
||||
@@ -6,7 +6,8 @@ let v = new Viewer({ container: document.getElementById('renderer'), showStats:
|
||||
window.v = v
|
||||
|
||||
window.LoadData = async function LoadData(url) {
|
||||
await v.loadObject(url, token)
|
||||
// token is not used in this context, since the preview service talks directly to the DB
|
||||
await v.loadObject(url, undefined)
|
||||
}
|
||||
|
||||
window.onload = () => {
|
||||
|
||||
@@ -9,7 +9,7 @@ const { pipeline, PassThrough } = require('stream')
|
||||
let router = express.Router()
|
||||
|
||||
// This method was copy-pasted from the server method, without authentication/authorization (this web service is an internal one)
|
||||
router.get('/:streamId/:objectId', async function (req, res, next) {
|
||||
router.get('/:streamId/:objectId', async function (req, res) {
|
||||
// Populate first object (the "commit")
|
||||
let obj = await getObject({
|
||||
streamId: req.params.streamId,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
'use strict'
|
||||
/* eslint-disable */
|
||||
|
||||
let express = require('express')
|
||||
let router = express.Router()
|
||||
@@ -151,7 +152,7 @@ async function getScreenshot(objectUrl) {
|
||||
// return imageBuffer
|
||||
}
|
||||
|
||||
router.get('/:streamId/:objectId', async function (req, res, next) {
|
||||
router.get('/:streamId/:objectId', async function (req, res) {
|
||||
let objectUrl = `http://127.0.0.1:3001/streams/${req.params.streamId}/objects/${req.params.objectId}`
|
||||
/*
|
||||
let authToken = ''
|
||||
|
||||
@@ -79,7 +79,7 @@ exports.buildApolloServer = (optionOverrides) => {
|
||||
metricConnectedClients.dec()
|
||||
}
|
||||
},
|
||||
plugins: [require(`${appRoot}/logging/apolloPlugin`)],
|
||||
plugins: [require('@/logging/apolloPlugin')],
|
||||
tracing: debug,
|
||||
introspection: true,
|
||||
playground: true,
|
||||
|
||||
@@ -11,6 +11,7 @@ const metricCallCount = new prometheusClient.Counter({
|
||||
})
|
||||
|
||||
module.exports = {
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
requestDidStart(ctx) {
|
||||
return {
|
||||
didResolveOperation(ctx) {
|
||||
|
||||
@@ -134,70 +134,68 @@ module.exports = {
|
||||
|
||||
let ids = []
|
||||
|
||||
let promises = batches.map(
|
||||
async (batch, index) =>
|
||||
new Promise(async (resolve, reject) => {
|
||||
let closures = []
|
||||
let objsToInsert = []
|
||||
const insertBatch = async (batch, index) => {
|
||||
let closures = []
|
||||
let objsToInsert = []
|
||||
|
||||
let t0 = performance.now()
|
||||
let t0 = performance.now()
|
||||
|
||||
batch.forEach((obj) => {
|
||||
if (!obj) return
|
||||
batch.forEach((obj) => {
|
||||
if (!obj) return
|
||||
|
||||
let insertionObject = prepInsertionObject(streamId, obj)
|
||||
let totalChildrenCountByDepth = {}
|
||||
let totalChildrenCountGlobal = 0
|
||||
if (obj.__closure !== null) {
|
||||
for (const prop in obj.__closure) {
|
||||
closures.push({
|
||||
streamId: streamId,
|
||||
parent: insertionObject.id,
|
||||
child: prop,
|
||||
minDepth: obj.__closure[prop]
|
||||
})
|
||||
let insertionObject = prepInsertionObject(streamId, obj)
|
||||
let totalChildrenCountByDepth = {}
|
||||
let totalChildrenCountGlobal = 0
|
||||
if (obj.__closure !== null) {
|
||||
for (const prop in obj.__closure) {
|
||||
closures.push({
|
||||
streamId: streamId,
|
||||
parent: insertionObject.id,
|
||||
child: prop,
|
||||
minDepth: obj.__closure[prop]
|
||||
})
|
||||
|
||||
totalChildrenCountGlobal++
|
||||
totalChildrenCountGlobal++
|
||||
|
||||
if (totalChildrenCountByDepth[obj.__closure[prop].toString()])
|
||||
totalChildrenCountByDepth[obj.__closure[prop].toString()]++
|
||||
else totalChildrenCountByDepth[obj.__closure[prop].toString()] = 1
|
||||
}
|
||||
}
|
||||
|
||||
insertionObject.totalChildrenCount = totalChildrenCountGlobal
|
||||
insertionObject.totalChildrenCountByDepth = JSON.stringify(
|
||||
totalChildrenCountByDepth
|
||||
)
|
||||
|
||||
delete insertionObject.__tree
|
||||
delete insertionObject.__closure
|
||||
|
||||
objsToInsert.push(insertionObject)
|
||||
ids.push(insertionObject.id)
|
||||
})
|
||||
|
||||
if (objsToInsert.length > 0) {
|
||||
let queryObjs =
|
||||
Objects().insert(objsToInsert).toString() + ' on conflict do nothing'
|
||||
await knex.raw(queryObjs)
|
||||
if (totalChildrenCountByDepth[obj.__closure[prop].toString()])
|
||||
totalChildrenCountByDepth[obj.__closure[prop].toString()]++
|
||||
else totalChildrenCountByDepth[obj.__closure[prop].toString()] = 1
|
||||
}
|
||||
}
|
||||
|
||||
if (closures.length > 0) {
|
||||
let q2 = `${Closures().insert(closures).toString()} on conflict do nothing`
|
||||
await knex.raw(q2)
|
||||
}
|
||||
insertionObject.totalChildrenCount = totalChildrenCountGlobal
|
||||
insertionObject.totalChildrenCountByDepth = JSON.stringify(
|
||||
totalChildrenCountByDepth
|
||||
)
|
||||
|
||||
let t1 = performance.now()
|
||||
debug(
|
||||
`Batch ${index + 1}/${batches.length}: Stored ${
|
||||
closures.length + objsToInsert.length
|
||||
} objects in ${t1 - t0}ms.`
|
||||
)
|
||||
// console.log( `Batch ${index + 1}/${batches.length}: Stored ${closures.length + objsToInsert.length} objects in ${t1-t0}ms.` )
|
||||
resolve()
|
||||
})
|
||||
)
|
||||
delete insertionObject.__tree
|
||||
delete insertionObject.__closure
|
||||
|
||||
objsToInsert.push(insertionObject)
|
||||
ids.push(insertionObject.id)
|
||||
})
|
||||
|
||||
if (objsToInsert.length > 0) {
|
||||
let queryObjs =
|
||||
Objects().insert(objsToInsert).toString() + ' on conflict do nothing'
|
||||
await knex.raw(queryObjs)
|
||||
}
|
||||
|
||||
if (closures.length > 0) {
|
||||
let q2 = `${Closures().insert(closures).toString()} on conflict do nothing`
|
||||
await knex.raw(q2)
|
||||
}
|
||||
|
||||
let t1 = performance.now()
|
||||
debug(
|
||||
`Batch ${index + 1}/${batches.length}: Stored ${
|
||||
closures.length + objsToInsert.length
|
||||
} objects in ${t1 - t0}ms.`
|
||||
)
|
||||
// console.log( `Batch ${index + 1}/${batches.length}: Stored ${closures.length + objsToInsert.length} objects in ${t1-t0}ms.` )
|
||||
}
|
||||
|
||||
let promises = batches.map((batch, index) => insertBatch(batch, index))
|
||||
|
||||
await Promise.all(promises)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user