-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/1382 changes to inactive workplaces report updated #6090
base: main
Are you sure you want to change the base?
Feat/1382 changes to inactive workplaces report updated #6090
Conversation
… running it locally
…o reduce chance of deadlock/time where the view is unavailable
const stopViewRefresh = _req.query?.stopViewRefresh; | ||
try { | ||
if (stopViewRefresh !== 'true' || !stopViewRefresh) { | ||
await inactiveWorkplacesUtils.refreshEstablishmentLastActivityView(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems that we are doing this check in multiple places. Would it be good if we extract them to a function, so that the logic are kept in one place?
for example:
const refreshViewIfNecessary = async (req) => {
const stopViewRefresh = req.query?.stopViewRefresh;
if (stopViewRefresh !== 'true' || !stopViewRefresh) {
await inactiveWorkplacesUtils.refreshEstablishmentLastActivityView();
}
};
and then, in the try block we can replace the if branch in line 15 ~ 17, 36 ~ 38 and 51 ~ 53 by calling await refreshViewIfNecessary(_req)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have now put the duplicated code in a util
Work done
Tests
Does this PR include tests for the changes introduced?