Skip to content

Commit

Permalink
Merge branch 'main' into fix-unknown
Browse files Browse the repository at this point in the history
  • Loading branch information
sjvans authored Nov 7, 2024
2 parents 4421ee7 + 9bbb1b1 commit 8d85193
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,29 @@ const addDataSubjectForDetailsEntity = (row, log, req, entity, model) => {
else map.set(role, _getDataSubjectIdQuery(dataSubjectInfo, row, model))
}

const resolveDataSubjects = async (logs, req) => {
const resolveDataSubjects = (logs, req) => {
const ps = []

const map = _getDataSubjectsMap(req)

for (const each of Object.values(logs)) {
if (each.data_subject.id instanceof cds.ql.Query) {
const q = each.data_subject.id
if (map.has(q)) {
each.data_subject.id = map.get(q)
} else {
const res = await q
map.set(q, res)
each.data_subject.id = res
if (!map.has(q)) {
const p = cds.run(q).then(res => map.set(q, res))
map.set(q, p)
ps.push(p)
}
}
}

return Promise.all(ps).then(() => {
for (const each of Object.values(logs)) {
if (each.data_subject.id instanceof cds.ql.Query) {
each.data_subject.id = map.get(each.data_subject.id)
}
}
})
}

module.exports = {
Expand Down

0 comments on commit 8d85193

Please sign in to comment.