refactor blockcount
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
ale 2024-11-15 20:03:32 +01:00
parent 6b6ebb7cbf
commit b44e199d1d
2 changed files with 5 additions and 17 deletions

View File

@ -481,21 +481,9 @@ module.exports = (app, client) => {
parser(),
pick({ filter: 'hits.hits' }),
streamArray(),
data => data.value._source
data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment })
])
pipeline.on('data', data => {
block_count++
instancescomment.push({
instance: data.instance, comment: data.blocks.find(block => block.domain === clean(req.params.instance)).comment
})
})
pipeline.on('end', () => {
res.json({
block_count,
instances: instancescomment
})
})
result.pipe(pipeline)
result.pipe(pipeline).pipe(res, { end: true })
} else {
res.status(404).end()
}

View File

@ -38,8 +38,8 @@ document.addEventListener('DOMContentLoaded', function () {
loading()
fetch('/api/block_count/' + content).then(async function (result) {
var res = await result.json()
if (res && res.block_count >= 0) {
document.getElementById('blockcount').innerText = res.block_count
if (Array.isArray(res) && res?.length >= 0) {
document.getElementById('blockcount').innerText = res.length
document.getElementById('blockinstance').innerText = 'ing ' + content
document.getElementById('blocktook').innerText = ''
var list = document.getElementById('blocklist'),
@ -50,7 +50,7 @@ document.addEventListener('DOMContentLoaded', function () {
while (list.hasChildNodes()) {
list.removeChild(list.firstChild)
}
res.instances.map(function (instance, index) {
res.map(function (instance, index) {
var li = document.createElement('li'),
text = document.createTextNode((index + 1) + '. '),
link = '<a href="/' + (new URLSearchParams(window.location.search).has('matrix') ? '?matrix' : '') + '#' + instance.instance + '" onclick="window.location.href=this.href; window.location.reload(false);">' + instance.instance + '</a>',