Merge pull request #33 in ~VLE2FE/definma-api from develop to master
* commit '37a5ba1bfd6db80f27df879fa28d8d43966dc9c0': fixed measurements lookup pipeline
This commit is contained in:
commit
b104727c07
@ -230,8 +230,11 @@ router.get('/samples', async (req, res, next) => {
|
|||||||
{$eq: ['$sample_id', '$$sId']},
|
{$eq: ['$sample_id', '$$sId']},
|
||||||
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
||||||
]}}},
|
]}}},
|
||||||
{$project: filters.fields.filter(e => /measurements\./.test(e))
|
{$project: _.merge(
|
||||||
.map(e => 'values.' + e.replace('measurements.', '')).reduce((s, e) => {s[e] = true; return s; }, {})}
|
filters.fields.filter(e => /measurements\./.test(e))
|
||||||
|
.map(e => 'values.' + e.split('.')[2]).reduce((s, e) => {s[e] = true; return s; }, {}),
|
||||||
|
{measurement_template: true, status: true, sample_id: true}
|
||||||
|
)}
|
||||||
],
|
],
|
||||||
as: 'measurements'
|
as: 'measurements'
|
||||||
}});
|
}});
|
||||||
@ -328,8 +331,11 @@ router.get('/samples', async (req, res, next) => {
|
|||||||
{$eq: ['$sample_id', '$$sId']},
|
{$eq: ['$sample_id', '$$sId']},
|
||||||
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
{$in: ['$measurement_template', measurementTemplates.map(e => mongoose.Types.ObjectId(e._id))]}
|
||||||
]}}},
|
]}}},
|
||||||
{$project: filters.fields.filter(e => /measurements\./.test(e))
|
{$project: _.merge(
|
||||||
.map(e => 'values.' + e.replace('measurements.', '')).reduce((s, e) => {s[e] = true; return s; }, {})}
|
filters.fields.filter(e => /measurements\./.test(e))
|
||||||
|
.map(e => 'values.' + e.split('.')[2]).reduce((s, e) => {s[e] = true; return s; }, {}),
|
||||||
|
{measurement_template: true, status: true, sample_id: true}
|
||||||
|
)}
|
||||||
],
|
],
|
||||||
as: 'measurements'
|
as: 'measurements'
|
||||||
}});
|
}});
|
||||||
|
Reference in New Issue
Block a user