Skip to content
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

ONI-132: Changing mutation code to handle autogeneration. #206

Merged
merged 2 commits into from
Aug 18, 2023

Conversation

ghost
Copy link

@ghost ghost commented Aug 7, 2023

Ticket:https://openimis.atlassian.net/browse/ONI-132

Changes:

  • Added code for handling of autogeneration of fields during mutation.

@ghost ghost requested a review from dborowiecki August 7, 2023 07:59
Copy link
Contributor

@malinowskikam malinowskikam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comment.

core/schema.py Outdated
Comment on lines 266 to 278
if mutation_data.get('autogenerate_code', None):
returned = cls.async_mutate(info.context.user if info.context and info.context.user else None,
**mutation_data)

if isinstance(returned, Dict):
data.update(returned)
error_messages = None
else:
error_messages = returned
else:
error_messages = cls.async_mutate(
info.context.user if info.context and info.context.user else None,
**mutation_data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code can be expressed as:

Suggested change
if mutation_data.get('autogenerate_code', None):
returned = cls.async_mutate(info.context.user if info.context and info.context.user else None,
**mutation_data)
if isinstance(returned, Dict):
data.update(returned)
error_messages = None
else:
error_messages = returned
else:
error_messages = cls.async_mutate(
info.context.user if info.context and info.context.user else None,
**mutation_data)
messages = cls.async_mutate(info.context.user if info.context and info.context.user else None, **mutation_data)
if mutation_data.get('autogenerate_code', False) and isinstance(messages, Dict):
data.update(messages)
error_messages = None
else:
error_messages = messages

@sonarcloud
Copy link

sonarcloud bot commented Aug 18, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@dborowiecki dborowiecki merged commit 50bc1ed into develop Aug 18, 2023
5 checks passed
@dborowiecki dborowiecki deleted the feature/ONI-132 branch August 18, 2023 08:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants