Skip to content

Commit

Permalink
cache freeze option for single request to improve import performance
Browse files Browse the repository at this point in the history
  • Loading branch information
pofider committed Aug 17, 2023
1 parent 17b9380 commit fb48967
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/jsreport-freeze/lib/freeze.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,15 @@ function hookListeners (colName, col, rejectIfAppropriate) {

module.exports = (reporter, definition) => {
function rejectIfAppropriate (req) {
const freeze = req?.context?._cachedFreeze != null ? req.context._cachedFreeze : reporter.settings.findValue('freeze')
return Promise.all([
reporter.settings.findValue('freeze'),
freeze,
isAdminUserAuthenticated(reporter, req)
]).then(function ([freeze, isAdmin]) {
if (req?.context) {
req.context._cachedFreeze = freeze != null && freeze
}

if (isAdmin && !definition.options.hardFreeze && !freeze) {
return
}
Expand Down

0 comments on commit fb48967

Please sign in to comment.