Skip to content

Commit

Permalink
fix(edit-logs): fixes combined options action = create or delete, and…
Browse files Browse the repository at this point in the history
… accessMonitoring
  • Loading branch information
naholyr committed Sep 7, 2017
1 parent 6cfc111 commit fad3f82
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion server/routes/editLog.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ function getEditLog(req, res){
const paths = getAccessMonitoringPaths(mongoModel, query.accessMonitoring)
.concat(query.path ? [query.path] : [])
debug({paths})
mongoQuery['diff'] = {'$elemMatch': {'$or': paths.map(path=>({path})) }}
if (query.action === 'create' || query.action === 'delete') {
mongoQuery['$or'] = paths.map(path => ({ ['data.' + path]: {$exists: true} }))
} else {
mongoQuery['diff'] = {'$elemMatch': {'$or': paths.map(path=>({path})) }}
}
}

if (query.action)
Expand All @@ -178,6 +182,7 @@ function getEditLog(req, res){
else
mongoQuery['date']= {'$lte': endDate}
}
debug('Query', mongoQuery)
let aggregationPipeline = [
{'$match':mongoQuery},
{'$lookup':{
Expand Down

0 comments on commit fad3f82

Please sign in to comment.