download index
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
ale 2024-09-23 03:38:18 +02:00
parent 885576a746
commit ea7de88a33
2 changed files with 14 additions and 11 deletions

View File

@ -504,7 +504,7 @@ module.exports = (app, client) => {
app.use('/api/download_index', async (req, res) => { app.use('/api/download_index', async (req, res) => {
try { try {
res.setHeader('Content-Type', 'application/x-gzip') res.setHeader('Content-Type', 'application/x-gzip')
res.setHeader('Content-disposition', 'attachment; filename=fediblock-index.json.gz') res.setHeader('Content-disposition', 'attachment; filename=fediblock-index.jsonl.gz')
const result = await client.search({ const result = await client.search({
index: constant.index, index: constant.index,
size: 9999, size: 9999,
@ -516,15 +516,18 @@ module.exports = (app, client) => {
result, result,
parser(), parser(),
streamValues(), streamValues(),
data => [data.value.hits.hits.map(hit => ({ data => data.value.hits.hits,
instance: hit._source.instance, streamArray(),
blocks: hit._source.blocks, data => ({
api: hit._source.api, instance: data.value._source.instance,
last: hit._source.last, blocks: data.value._source.blocks,
nodeinfo: hit._source.nodeinfo api: data.value._source.api,
}))], last: data.value._source.last,
zlib.createGzip() nodeinfo: data.value._source.nodeinfo
]).pipe(res, { end: true }) }),
zlib.createGzip(),
res
])
} catch (e) { } catch (e) {
console.error(e) console.error(e)
res.status(404).end() res.status(404).end()

View File

@ -115,7 +115,7 @@ document.addEventListener('DOMContentLoaded', function () {
fetch('/api/download_index', { signal: ac.signal }).then(async function (result) { fetch('/api/download_index', { signal: ac.signal }).then(async function (result) {
var res = await result.blob(), var res = await result.blob(),
a = document.createElement('a') a = document.createElement('a')
a.download = 'fediblock-index.json.gz' a.download = 'fediblock-index.jsonl.gz'
a.href = URL.createObjectURL(res) a.href = URL.createObjectURL(res)
a.type = 'application/x-gzip' a.type = 'application/x-gzip'
a.target = '_blank' a.target = '_blank'