diff --git a/app/controllers/copy_controller.js b/app/controllers/copy_controller.js index f8c858e3..97d6ba07 100644 --- a/app/controllers/copy_controller.js +++ b/app/controllers/copy_controller.js @@ -133,9 +133,9 @@ function handleCopyFrom (logger) { return function handleCopyFromMiddleware (req, res, next) { const sql = req.query.q; const { userDbParams, user } = res.locals; - const gzip = req.get('content-encoding') === 'gzip'; + const isGzip = req.get('content-encoding') === 'gzip'; - let metrics = new StreamCopyMetrics(logger, 'copyfrom', sql, user, gzip); + let metrics = new StreamCopyMetrics(logger, 'copyfrom', sql, user, isGzip); streamCopy.from( sql, @@ -172,7 +172,7 @@ function handleCopyFrom (logger) { } }) .on('data', data => { - if (gzip) { + if (isGzip) { metrics.addGzipSize(data.length); } else { metrics.addSize(data.length); @@ -181,7 +181,7 @@ function handleCopyFrom (logger) { .on('end', () => requestEnded = true); - if (gzip) { + if (isGzip) { req .pipe(zlib.createGunzip()) .on('data', data => metrics.addSize(data.length)) diff --git a/app/services/stream_copy_metrics.js b/app/services/stream_copy_metrics.js index 24143a0d..7d6946be 100644 --- a/app/services/stream_copy_metrics.js +++ b/app/services/stream_copy_metrics.js @@ -1,12 +1,12 @@ const { getFormatFromCopyQuery } = require('../utils/query_info'); module.exports = class StreamCopyMetrics { - constructor(logger, type, sql, user, gzip = null) { + constructor(logger, type, sql, user, isGzip = null) { this.logger = logger; this.type = type; this.format = getFormatFromCopyQuery(sql); - this.gzip = gzip; + this.isGzip = isGzip; this.username = user; this.size = 0; this.gzipSize = 0; @@ -49,7 +49,7 @@ module.exports = class StreamCopyMetrics { this._log( this.startTime.toISOString(), - this.gzip && this.gzipSize ? this.gzipSize : null, + this.isGzip && this.gzipSize ? this.gzipSize : null, this.error ? this.error.message : null ); } @@ -60,7 +60,7 @@ module.exports = class StreamCopyMetrics { format: this.format, size: this.size, rows: this.rows, - gzip: this.gzip, + gzip: this.isGzip, username: this.username, time: this.time, timestamp