-
Notifications
You must be signed in to change notification settings - Fork 15
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
Bai 1247 create a basic read only model #1282
Conversation
…ns when an mirror model is used. Also added unit tests and resolved exsisting unit tests that were affected by refactored code.
backend/src/services/model.ts
Outdated
@@ -32,6 +32,9 @@ export async function createModel(user: UserInterface, modelParams: CreateModelP | |||
}) | |||
|
|||
const auth = await authorisation.model(user, model, ModelAction.Create) | |||
if (model.settings.mirror.sourceModelId && model.settings.mirror.destinationModelId) { |
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.
I think you should move this check to the start of the function and check the contents of modelParams.settings
backend/src/services/model.ts
Outdated
export async function updateModel( | ||
user: UserInterface, | ||
modelId: string, | ||
modelDiff: Partial<UpdateModelParams>, |
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.
Why not include settings in the model? What makes settings special?
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.
Ah. Presumably because we only use Object.assign()
below, which isn't recursive. I would prefer a recursive merging here, as opposed to treating 'settings' as a special case. I think something like:
.mergeWith({}, model, modelDiff, (a, b) =>
_.isArray(b) ? b : undefined
);
Might work.
No description provided.