* Adding a `size` property to all job-reporting meta-data and showing in reporting details pane
This commit is contained in:
parent
e69ca8d5eb
commit
b111074004
|
@ -70,7 +70,7 @@ function executeJobFn(server) {
|
|||
const maxSizeBytes = config.get('xpack.reporting.csv.maxSizeBytes');
|
||||
const scroll = config.get('xpack.reporting.csv.scroll');
|
||||
|
||||
const { content, maxSizeReached } = await generateCsv({
|
||||
const { content, maxSizeReached, size } = await generateCsv({
|
||||
searchRequest,
|
||||
fields,
|
||||
formatsMap,
|
||||
|
@ -89,7 +89,8 @@ function executeJobFn(server) {
|
|||
return {
|
||||
content_type: 'text/csv',
|
||||
content,
|
||||
max_size_reached: maxSizeReached
|
||||
max_size_reached: maxSizeReached,
|
||||
size,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -63,4 +63,18 @@ describe('MaxSizeStringBuilder', function () {
|
|||
expect(builder.getString()).to.be('a');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getSizeInBytes', function () {
|
||||
it(`should return 0 when no strings have been appended`, function () {
|
||||
const builder = new MaxSizeStringBuilder(100);
|
||||
expect(builder.getSizeInBytes()).to.be(0);
|
||||
});
|
||||
|
||||
it(`should the size in bytes`, function () {
|
||||
const builder = new MaxSizeStringBuilder(100);
|
||||
const stringValue = 'foobar';
|
||||
builder.tryAppend(stringValue);
|
||||
expect(builder.getSizeInBytes()).to.be(stringValue.length);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -58,11 +58,13 @@ export function createGenerateCsv(logger) {
|
|||
} finally {
|
||||
await iterator.return();
|
||||
}
|
||||
const size = builder.getSizeInBytes();
|
||||
logger(`finished generating, total size in bytes: ${size}`);
|
||||
|
||||
logger('finished generating');
|
||||
return {
|
||||
content: builder.getString(),
|
||||
maxSizeReached
|
||||
maxSizeReached,
|
||||
size,
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@ export class MaxSizeStringBuilder {
|
|||
return false;
|
||||
}
|
||||
|
||||
getSizeInBytes() {
|
||||
return this._size;
|
||||
}
|
||||
|
||||
getString() {
|
||||
return this._buffer.slice(0, this._size).toString();
|
||||
}
|
||||
|
|
|
@ -26,7 +26,8 @@ function executeJobFn(server) {
|
|||
}),
|
||||
map(buffer => ({
|
||||
content_type: 'image/png',
|
||||
content: buffer.toString('base64')
|
||||
content: buffer.toString('base64'),
|
||||
size: buffer.byteLength,
|
||||
}))
|
||||
);
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ function executeJobFn(server) {
|
|||
}),
|
||||
map(buffer => ({
|
||||
content_type: 'application/pdf',
|
||||
content: buffer.toString('base64')
|
||||
content: buffer.toString('base64'),
|
||||
size: buffer.byteLength,
|
||||
}))
|
||||
);
|
||||
|
||||
|
|
|
@ -126,6 +126,10 @@ export class ReportInfoButton extends Component<Props, State> {
|
|||
title: 'Content Type',
|
||||
description: get(info, 'output.content_type') || NA,
|
||||
},
|
||||
{
|
||||
title: 'Size in Bytes',
|
||||
description: get(info, 'output.size') || NA,
|
||||
},
|
||||
],
|
||||
status: [
|
||||
{
|
||||
|
|
|
@ -27,7 +27,10 @@ export interface JobInfo {
|
|||
jobtype: string;
|
||||
created_by: string;
|
||||
timeout: number;
|
||||
output: { content_type: string };
|
||||
output: {
|
||||
content_type: string;
|
||||
size: number;
|
||||
};
|
||||
process_expiration: string;
|
||||
completed_at: string;
|
||||
payload: {
|
||||
|
|
|
@ -58,6 +58,7 @@ const schema = {
|
|||
type: 'object',
|
||||
properties: {
|
||||
content_type: { type: 'keyword' },
|
||||
size: { type: 'keyword' },
|
||||
content: { type: 'object', enabled: false }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,6 +184,7 @@ export class Worker extends events.EventEmitter {
|
|||
docOutput.content = output.content;
|
||||
docOutput.content_type = output.content_type || unknownMime;
|
||||
docOutput.max_size_reached = output.max_size_reached;
|
||||
docOutput.size = output.size;
|
||||
} else {
|
||||
docOutput.content = output || defaultOutput;
|
||||
docOutput.content_type = unknownMime;
|
||||
|
|
Loading…
Reference in a new issue