|
1 | 1 | /* eslint-disable no-underscore-dangle, no-async-promise-executor */ |
2 | 2 | const fp = require('fastify-plugin'); |
| 3 | +const _ = require('underscore'); |
3 | 4 | const toArrayBuffer = require('to-array-buffer'); |
4 | 5 | // eslint-disable-next-line no-global-assign |
5 | 6 | window = {}; |
@@ -176,7 +177,7 @@ async function couchdb(fastify, options) { |
176 | 177 | Promise.all([bodySeriesInfo, bodyStudies]) |
177 | 178 | .then(values => { |
178 | 179 | const studies = {}; |
179 | | - studies.rows = values[1].rows.filter(obj => |
| 180 | + studies.rows = _.filter(values[1].rows, obj => |
180 | 181 | fastify.queryObj(request.query, obj.key[1], queryKeys) |
181 | 182 | ); |
182 | 183 | const res = []; |
@@ -222,7 +223,7 @@ async function couchdb(fastify, options) { |
222 | 223 | // if both studies have values, cumulate them but don't make duplicates |
223 | 224 | (typeof studySeriesObj[tag].Value[0] === 'string' && |
224 | 225 | !studySeriesObj[tag].Value.includes(val)) || |
225 | | - !studySeriesObj[tag].Value.findIndex(val) === -1 |
| 226 | + !_.findIndex(studySeriesObj[tag].Value, val) === -1 |
226 | 227 | ) { |
227 | 228 | studySeriesObj[tag].Value.push(val); |
228 | 229 | } |
@@ -743,7 +744,7 @@ async function couchdb(fastify, options) { |
743 | 744 | }, |
744 | 745 | async (error, body) => { |
745 | 746 | if (!error) { |
746 | | - const docs = body.rows.map(instance => { |
| 747 | + const docs = _.map(body.rows, instance => { |
747 | 748 | return { _id: instance.key[2], _rev: instance.doc._rev, _deleted: true }; |
748 | 749 | }); |
749 | 750 | await fastify.dbPqueue.add(() => { |
@@ -787,7 +788,7 @@ async function couchdb(fastify, options) { |
787 | 788 | }, |
788 | 789 | async (error, body) => { |
789 | 790 | if (!error) { |
790 | | - const docs = body.rows.map(instance => { |
| 791 | + const docs = _.map(body.rows, instance => { |
791 | 792 | return { _id: instance.key[2], _rev: instance.doc._rev, _deleted: true }; |
792 | 793 | }); |
793 | 794 | await fastify.dbPqueue.add(() => { |
|
0 commit comments