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

Refactor/split create update answers #98

Open
wants to merge 52 commits into
base: main
Choose a base branch
from

Conversation

maddaicita
Copy link

This pull request introduces a clear separation between the logic for creating and updating answer records associated with responses. Previously, a single method create_update_answers handled both creation and updating, which worked well but did not align with the single-responsibility principle.

The changes split this functionality into two distinct methods: create_answers and update_answers. This ensures that each method has a single responsibility and improves the overall readability and maintainability of the codebase.

Key Changes:

create_answers: Iterates through provided answers and creates new Answer records only if they do not already exist.
update_answers: Specifically targets existing Answer records and applies updates, ensuring that the state of an Answer is kept consistent and up-to-date with the latest response.

By refactoring this logic, we also enhance error handling and make debugging more straightforward. These changes are expected to facilitate future extensions of the response and answer features without adding complexity to the existing logic.

Deana Franks added 30 commits February 27, 2024 23:03
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.

1 participant