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

Add Custom Fields Feature for Project Issues and Implement Associated CRUD Operations #21

Merged
merged 3 commits into from
Jan 1, 2024

Conversation

claygorman
Copy link
Contributor

@claygorman claygorman commented Dec 29, 2023

Type

enhancement, bug_fix


Description

  • Introduce custom fields feature for project issues, allowing tracking of additional custom fields with various types (text, number, date, boolean).
  • Implement CRUD operations for custom fields, including GraphQL mutations for creating and deleting project custom fields.
  • Add a new 'project_custom_fields' table and a 'custom_fields' JSONB column to the 'issues' table through migrations.
  • Update the 'Issue' model to include the 'customFields' field.
  • Define the 'ProjectCustomField' model and integrate it into the Sequelize model index.
  • Add error handling for missing token in the context function of the backend.
  • Enhance the 'updateIssue' mutation to handle custom field values and add a resolver for the 'CustomFieldValue' type.
  • Provide GraphQL mutations for creating and deleting project custom fields and a resolver for fetching custom fields of a project.
  • Extend GraphQL schema with type definitions for custom fields and custom field values, and include 'customFields' in the 'Issue' type.

PR changes walkthrough

Relevant files                                                                                                                                 
Enhancement
8 files
20231228152900-add-custom-fields.js                                                 
    backend/src/db/migrations/20231228152900-add-custom-fields.js

    Add a new migration to create the 'project_custom_fields'
    table with fields for id, projectId, fieldName, fieldType,
    createdAt, and updatedAt.

+52/-0
20231228153315-add-issue-custom-field-values.js                         
    backend/src/db/migrations/20231228153315-add-issue-custom-field-values.js

    Add a new migration to add a 'custom_fields' JSONB column to
    the 'issues' table.

+16/-0
index.js                                                                                                       
    backend/src/db/models/index.js

    Import and initialize the 'ProjectCustomFields' model.

+11/-9
issue.js                                                                                                       
    backend/src/db/models/issue.js

    Add 'customFields' JSONB field to the 'Issue' model.

+4/-0
project-custom-fields.js                                                                       
    backend/src/db/models/project-custom-fields.js

    Define the 'ProjectCustomField' model with fields for id,
    projectId, fieldName, fieldType, createdAt, and updatedAt.

+51/-0
index.js                                                                                                       
    backend/src/resolvers/Issue/index.js

    Implement custom field value handling in the 'updateIssue'
    mutation and add a 'CustomFieldValue' type resolver.

+42/-1
index.js                                                                                                       
    backend/src/resolvers/Project/index.js

    Add mutations for creating and deleting project custom
    fields and a resolver to fetch custom fields for a project.

+25/-3
type-defs.js                                                                                               
    backend/src/type-defs.js

    Add GraphQL type definitions for custom fields and custom
    field values, and update the 'Issue' type to include
    'customFields'.

+46/-0
Bug_fix
1 files
index.js                                                                                                       
    backend/src/index.js

    Add a check to return early from the context function if no
    token is present.

+2/-0

This adds the ability to track additional custom fields for project issues. These custom fields can be of various types (text, number, date, boolean), and are identified by a custom field id. Along with this, CRUD operations for these custom fields have also been implemented, including newly defined GraphQL mutations for creating and deleting project custom fields. To store these custom field values at the database level, additional columns have been added to the 'issues' table in a new migration file, and these values can be updated using the existing 'updateIssue' mutation under resolvers.
Copy link
Contributor

PR Analysis

  • 🎯 Main theme: Adding custom fields feature to project issues
  • 📝 PR summary: This PR introduces the ability to add custom fields to project issues. These fields can be of various types (text, number, date, boolean) and are identified by a custom field id. CRUD operations for these custom fields have also been implemented, including GraphQL mutations for creating and deleting project custom fields. The PR also includes database migrations to add the necessary columns to the 'issues' table to store these custom field values.
  • 📌 Type of PR: Enhancement
  • ⏱️ Estimated effort to review [1-5]: 4, because the PR involves changes in multiple files including database migrations, model definitions, GraphQL resolvers and type definitions. The logic for handling custom fields in issues is also complex and requires careful review.
  • 🔒 Security concerns: No security concerns found

PR Feedback

💡 General suggestions: The PR is well-structured and the changes are logically grouped. The use of Sequelize for database operations and GraphQL for API operations is consistent with best practices. However, there are several TODO comments indicating areas that need improvement or further investigation. It would be beneficial to address these before merging the PR.

🤖 Code feedback:
relevant filebackend/src/resolvers/Issue/index.js
suggestion      

Consider extracting the logic for handling custom fields into a separate function or module to improve code readability and maintainability. [important]

relevant lineif (customFieldId && customFieldValue) {

relevant filebackend/src/db/models/issue.js
suggestion      

It would be better to use ENUM for the 'fieldType' field in the 'ProjectCustomField' model to enforce data integrity at the database level. [medium]

relevant linefieldType: {

relevant filebackend/src/db/migrations/20231228152900-add-custom-fields.js
suggestion      

Consider adding a 'not null' constraint to the 'fieldName' and 'fieldType' fields in the 'project_custom_fields' table to ensure that these fields always have a value. [medium]

relevant linefieldName: {

relevant filebackend/src/db/models/project-custom-fields.js
suggestion      

Consider adding validation to the 'fieldType' field in the 'ProjectCustomField' model to ensure that it only accepts the predefined types (text, number, date, boolean). [medium]

relevant linefieldType: {

✨ Usage tips:

To invoke the PR-Agent, add a comment using one of the following commands:

  • /review: Request a review of your Pull Request.
  • /describe: Update the PR title and description based on the contents of the PR.
  • /improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
  • /ask <QUESTION>: Ask a question about the PR.
  • /update_changelog: Update the changelog based on the PR's contents.
  • /add_docs 💎: Generate docstring for new components introduced in the PR.
  • /generate_labels 💎: Generate labels for the PR based on the PR's contents.
  • /analyze 💎: Automatically analyzes the PR, and presents changes walkthrough for each component.

See the tools guide for more details.
To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

claygorman and others added 2 commits December 29, 2023 12:35
This commit revolves around updating the naming conventions for custom field values. The term 'customFieldValues' has been replaced with 'customFields' across various files. This has also impacted the logic managing these fields, with adapted models, migrations, and resolvers to instantly reflect the changes. The 'customFieldValues' method within the Issue resolver has been completely removed as it is no longer necessary, given the new naming convention.
@claygorman claygorman marked this pull request as ready for review January 1, 2024 22:37
@claygorman
Copy link
Contributor Author

/describe

@github-actions github-actions bot changed the title custom-fields Add Custom Fields Feature for Project Issues and Implement Associated CRUD Operations Jan 1, 2024
@github-actions github-actions bot added enhancement New feature or request bug_fix labels Jan 1, 2024
Copy link
Contributor

github-actions bot commented Jan 1, 2024

PR Description updated to latest commit (8e87461)

@claygorman claygorman merged commit a19e592 into master Jan 1, 2024
1 of 2 checks passed
@claygorman claygorman deleted the custom-fields branch January 1, 2024 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug_fix enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant