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

This commit is contained in:
ale 2024-11-15 20:50:56 +01:00
parent 832ae9ea34
commit 1fcadc150d

View File

@ -5,6 +5,7 @@ module.exports = (app, client) => {
{ parser } = require('stream-json'), { parser } = require('stream-json'),
{ streamArray } = require('stream-json/streamers/StreamArray'), { streamArray } = require('stream-json/streamers/StreamArray'),
{ chain } = require('stream-chain'), { chain } = require('stream-chain'),
{ stringer } = require('stream-json/jsonl/Stringer'),
clean = str => { clean = str => {
return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '') return str.replace(/[/\\^$+?()`'¡¿¨!"·%&=;,\|\[\]{}]+/gmi, '')
} }
@ -472,9 +473,12 @@ module.exports = (app, client) => {
parser(), parser(),
pick({ filter: 'hits.hits' }), pick({ filter: 'hits.hits' }),
streamArray(), streamArray(),
data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment }) data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment }),
stringer()
]) ])
result.pipe(pipeline).pipe(res, { end: true }) res.once('data', data => '[' + data.toString())
res.on('finish', () => res.end(']'))
result.pipe(pipeline).pipe(res)
} else { } else {
res.status(404).end() res.status(404).end()
} }