Skip to content

Conversation

ramraut-osm
Copy link
Contributor

@ramraut-osm ramraut-osm commented May 10, 2024

API PR Checklist

Pre-requisites

  • I have gone through the Contributing guidelines for Submitting a Pull Request (PR) and ensured that this is not a duplicate PR.
  • I have performed preliminary unit testing.
  • I have updated the required api docs as applicable.
  • I have added/updated test cases to the test suite as applicable

PR Details

PR details have been updated as per the given format (see below)

  • PR title adheres to the format specified in guidelines (e.g., feat: add admin login endpoint)
  • Description has been added
  • Related changes have been added (optional)
  • Screenshots have been added (optional)
  • Query request and response examples have been added (as applicable, in case added or updated)
  • Documentation changes have been listed (as applicable)
  • Test suite output is added (as applicable)
  • Pending actions have been added (optional)
  • Any other additional notes have been added (optional)

Additional Information

  • Appropriate label(s) have been added (ready for review should be added if the PR is ready to be reviewed)
  • Assignee(s) and reviewer(s) have been added (optional)

Description:

Added getAllRecords API which will fetch all the records from DB as per conditions mentioned in query.

Related changes:

  • Add short points about the different changes made within the files in this PR.

Screenshots:

Add any screenshots as required.

Query request and response:
Query:

  summaries(
    options: {
      limit: 10
      offset: 0
      sortOrder: ASC
      filters: [
        { field: "jobId", operator: "in", value: "[5,6]" }
      ]
    }
  ) {
    limit
    offset
    summaries {
      createdBy
      createdOn
      jobId
      inputFile
      jobStatus
      modifiedBy
      modifiedOn
      outputText
      status
    }
    total
  }
}

Response:

  "data": {
    "summaries": {
      "limit": 10,
      "offset": 0,
      "summaries": [
        {
          "createdBy": "admin",
          "createdOn": "2024-05-11T07:19:29.000Z",
          "jobId": 5,
          "inputFile": "98fc73e3-caec-4ff1-b24b-f9f74fee5f6d_uploadfileapi.json",
          "jobStatus": 1,
          "modifiedBy": "admin",
          "modifiedOn": "2024-05-11T07:19:29.000Z",
          "outputText": null,
          "status": 1
        },
        {
          "createdBy": "admin",
          "createdOn": "2024-05-11T07:19:34.000Z",
          "jobId": 6,
          "inputFile": "7a995221-b5f9-4a82-8518-c97f1b78c4a3_uploadfileapi.json",
          "jobStatus": 1,
          "modifiedBy": "admin",
          "modifiedOn": "2024-05-11T07:19:34.000Z",
          "outputText": null,
          "status": 1
        }
      ],
      "total": 2
    }
  }
}

Documentation changes:

  • Add a list of changes made to the API documents with brief descriptions.

Test suite output:

  • Add the output of the status of different test cases in the testing suite.

Pending actions:

  • Add list of any pending actions that have or would require to be done in this PR.

Additional notes:

  • Add list of any additional notes you may want to convey in this PR.

Summary by CodeRabbit

  • New Features
    • Added a new API request "FetchAllRecords" to fetch records with customizable options such as limit, offset, sortOrder, and filters.
  • Enhancements
    • Updated search and filter functionality in the API to support JSON string parsing and date conversions.
  • Database Changes
    • Modified database migration to add default values and update field types for job processing.
  • API Changes
    • Renamed outputFile to outputText in summary entities and made modifiedOn field nullable to enhance flexibility in data handling.

@ramraut-osm ramraut-osm added the Ready for review Ready for review label May 10, 2024
@ramraut-osm ramraut-osm requested a review from xixas May 10, 2024 09:27
@ramraut-osm ramraut-osm self-assigned this May 10, 2024
Copy link
Contributor

coderabbitai bot commented May 10, 2024

Walkthrough

This update enhances the API's database and entity management, refines GraphQL service operations, and expands the Postman collection. Key changes include modifications to database migration scripts, entity attribute updates, improved JSON and date handling in GraphQL services, and the addition of a new GraphQL query in the Postman collection.

Changes

File Path Change Summary
.../migrations/1715278578144-migration.ts Updated class name, added default values, changed input_file type, removed foreign key operations.
.../modules/summary/entities/summary.entity.ts Renamed outputFile to outputText, updated decorators to allow null, made modifiedOn nullable.
.../graphql/services/core.service.ts Enhanced constructor for better filter handling, added JSON parsing and date conversion.
.../Transcript Summarization.postman_collection.json Added "FetchAllRecords" request with POST method and included response data.

🐇✨
A hop here, a tweak there,
Code changes spread everywhere.
From fields that now can nullify,
To queries that deeply specify,
Each line refines, the API shines!
🌟📜


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Out of diff range and nitpick comments (1)
apps/api/src/modules/summary/dto/summary-response.dto.ts (1)

1-1: Ensure that all imported entities are used within the file to avoid unnecessary imports.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between d9ff540 and b8b3471.
Files ignored due to path filters (3)
  • apps/api/src/upload/3b5ce3d6-008e-49a5-978b-3f06568763ea_db2.jpg is excluded by !**/*.jpg
  • apps/api/src/upload/85cb702d-cb72-4c12-b83c-5e45004b63b8_db2.jpg is excluded by !**/*.jpg
  • apps/api/src/upload/cd641a77-d215-4ce5-b83c-73c7ddf2237d_Screenshot_2.jpg is excluded by !**/*.jpg
Files selected for processing (11)
  • apps/api/Transcript Summarization.postman_collection.json (1 hunks)
  • apps/api/src/config/typeorm/configuration.ts (1 hunks)
  • apps/api/src/database/migrations/1715278578144-migration.ts (4 hunks)
  • apps/api/src/main.ts (1 hunks)
  • apps/api/src/modules/summary/dto/summary-response.dto.ts (1 hunks)
  • apps/api/src/modules/summary/entities/summary.entity.ts (2 hunks)
  • apps/api/src/modules/summary/summary.resolver.ts (2 hunks)
  • apps/api/src/modules/summary/summary.service.ts (3 hunks)
  • apps/api/src/schema.gpl (1 hunks)
  • apps/api/src/upload/272d2fc7-1081-4684-ab7c-8d2e6aa0cb44_Transcript Summarizer Kickoff.vtt (1 hunks)
  • apps/api/src/upload/8ac6f94d-732a-4462-b6b9-ecdb991aebf3_example_1.json (1 hunks)
Files not summarized due to errors (1)
  • apps/api/src/upload/272d2fc7-1081-4684-ab7c-8d2e6aa0cb44_Transcript Summarizer Kickoff.vtt: Error: Message exceeds token limit
Files skipped from review due to trivial changes (2)
  • apps/api/src/schema.gpl
  • apps/api/src/upload/8ac6f94d-732a-4462-b6b9-ecdb991aebf3_example_1.json
Additional Context Used
GitHub Check Runs (1)
lint failure (3)

apps/api/src/modules/summary/summary.resolver.ts: [failure] 1-1:
'Int' is defined but never used

Additional comments not posted (58)
apps/api/src/modules/summary/dto/summary-response.dto.ts (1)

18-22: The constructor provides default values for offset and limit. This is a good practice as it ensures that these values are always initialized, preventing potential runtime errors.

apps/api/src/config/typeorm/configuration.ts (1)

19-19: Changing the migrationsTableName from 'jobs' to 'jobDetails' might require corresponding updates in existing migration scripts and database schemas to ensure consistency.

apps/api/src/modules/summary/summary.resolver.ts (1)

19-24: The findAll query method correctly uses the QueryOptionsDto to allow flexible querying. This is a good practice as it enhances the API's flexibility and usability.

apps/api/src/main.ts (1)

20-20: Reducing the number of files that can be uploaded simultaneously from 5 to 1 without adjusting the maximum file size might impact user experience. Consider whether this change aligns with user needs and system requirements.

apps/api/src/modules/summary/entities/summary.entity.ts (1)

22-31: Allowing outputText and modifiedOn to be nullable is a significant change. Ensure that this aligns with the business logic and that the database schema is updated accordingly to avoid data integrity issues.

apps/api/src/database/migrations/1715278578144-migration.ts (1)

Line range hint 22-52: The changes in default values and data types in the migration script should be carefully reviewed to ensure they align with the application's data handling and storage requirements.

Verification successful

The changes in default values and data types in the migration script are consistently reflected in the corresponding entity definitions within the application. Here are the specific points of alignment:

  • Input and Output Fields: Both input_file and output_text are defined with appropriate nullability in the entity file.
  • Timestamp Fields: The created_on and modified_on fields use the correct decorators in the entity file, aligning with their definitions in the migration script.
  • User Fields: The default values for created_by and modified_by are consistent between the migration script and the entity file.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify if the changes in the migration script are reflected in the corresponding entity definitions and used consistently across the application.

# Test: Search for entity definitions and usage of the changed fields. Expect: Consistent definitions and usage.
rg --type ts $'job_status'

Length of output: 258



Script:

#!/bin/bash
# Description: Verify if the changes in the migration script for other fields are reflected in the corresponding entity definitions and used consistently across the application.

# Test: Search for entity definitions and usage of the fields 'input_file', 'output_text', 'created_on', 'modified_on', 'created_by', 'modified_by'. Expect: Consistent definitions and usage.
rg --type ts $'input_file|output_text|created_on|modified_on|created_by|modified_by'

Length of output: 1342

apps/api/src/modules/summary/summary.service.ts (1)

Line range hint 15-68: Extending CoreService in SummaryService and implementing findAllJobs with dynamic query options enhances the modularity and reusability of the service. This is a good practice as it allows for more flexible data querying.

apps/api/Transcript Summarization.postman_collection.json (1)

74-118: The new POST request "FetchAllRecords" is well-defined with appropriate headers and a detailed GraphQL query. This addition should enhance the API testing capabilities and provide a practical way to test the new getAllRecords endpoint.

apps/api/src/upload/272d2fc7-1081-4684-ab7c-8d2e6aa0cb44_Transcript Summarizer Kickoff.vtt (50)

1-1: Ensure the file starts with the correct VTT header.


3-5: First dialogue segment is correctly formatted.


7-10: Second dialogue segment is correctly formatted.


12-14: Third dialogue segment is correctly formatted.


16-23: Fourth dialogue segment is correctly formatted.


25-31: Fifth dialogue segment is correctly formatted.


33-41: Sixth dialogue segment is correctly formatted.


43-47: Seventh dialogue segment is correctly formatted.


49-61: Eighth dialogue segment is correctly formatted.


63-67: Ninth dialogue segment is correctly formatted.


69-75: Tenth dialogue segment is correctly formatted.


77-83: Eleventh dialogue segment is correctly formatted.


85-93: Twelfth dialogue segment is correctly formatted.


95-99: Thirteenth dialogue segment is correctly formatted.


101-107: Fourteenth dialogue segment is correctly formatted.


109-121: Fifteenth dialogue segment is correctly formatted.


123-127: Sixteenth dialogue segment is correctly formatted.


129-137: Seventeenth dialogue segment is correctly formatted.


139-147: Eighteenth dialogue segment is correctly formatted.


149-152: Nineteenth dialogue segment is correctly formatted.


154-160: Twentieth dialogue segment is correctly formatted.


162-174: Twenty-first dialogue segment is correctly formatted.


176-188: Twenty-second dialogue segment is correctly formatted.


190-192: Twenty-third dialogue segment is correctly formatted.


194-206: Twenty-fourth dialogue segment is correctly formatted.


208-218: Twenty-fifth dialogue segment is correctly formatted.


220-222: Twenty-sixth dialogue segment is correctly formatted.


224-227: Twenty-seventh dialogue segment is correctly formatted.


229-231: Twenty-eighth dialogue segment is correctly formatted.


233-235: Twenty-ninth dialogue segment is correctly formatted.


237-239: Thirtieth dialogue segment is correctly formatted.


241-244: Thirty-first dialogue segment is correctly formatted.


246-248: Thirty-second dialogue segment is correctly formatted.


250-254: Thirty-third dialogue segment is correctly formatted.


256-260: Thirty-fourth dialogue segment is correctly formatted.


262-266: Thirty-fifth dialogue segment is correctly formatted.


268-270: Thirty-sixth dialogue segment is correctly formatted.


272-274: Thirty-seventh dialogue segment is correctly formatted.


276-278: Thirty-eighth dialogue segment is correctly formatted.


280-283: Thirty-ninth dialogue segment is correctly formatted.


285-287: Fortieth dialogue segment is correctly formatted.


289-292: Forty-first dialogue segment is correctly formatted.


294-296: Forty-second dialogue segment is correctly formatted.


298-305: Forty-third dialogue segment is correctly formatted.


307-310: Forty-fourth dialogue segment is correctly formatted.


312-314: Forty-fifth dialogue segment is correctly formatted.


316-319: Forty-sixth dialogue segment is correctly formatted.


321-324: Forty-seventh dialogue segment is correctly formatted.


326-330: Forty-eighth dialogue segment is correctly formatted.


332-334: Forty-ninth dialogue segment is correctly formatted.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b8b3471 and 9c413c5.
Files selected for processing (2)
  • apps/api/src/database/migrations/1715278578144-migration.ts (4 hunks)
  • apps/api/src/modules/summary/summary.resolver.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/api/src/database/migrations/1715278578144-migration.ts
  • apps/api/src/modules/summary/summary.resolver.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Out of diff range and nitpick comments (1)
apps/api/src/common/graphql/services/core.service.ts (1)

88-90: Use parameter expansion correctly for 'in' operator.

The use of parameter expansion in the 'in' operator condition is correct, but ensure that the value passed is always an array to avoid SQL errors. This ties back to the JSON parsing logic which should robustly handle errors to ensure value is an array.

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 9c413c5 and ff8ada5.
Files selected for processing (1)
  • apps/api/src/common/graphql/services/core.service.ts (4 hunks)
Additional comments not posted (1)
apps/api/src/common/graphql/services/core.service.ts (1)

60-61: Ensure type safety when converting string to Date.

The conversion of value to a Date object is implicitly cast back to a string. This could lead to potential type mismatches or errors in date comparisons. Verify that this conversion and the subsequent usage in the query are handled correctly.

ramraut-osm and others added 2 commits May 11, 2024 12:27
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between ff8ada5 and 70db786.
Files selected for processing (2)
  • apps/api/src/database/migrations/1715278578144-migration.ts (3 hunks)
  • apps/api/src/modules/summary/entities/summary.entity.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/api/src/database/migrations/1715278578144-migration.ts
  • apps/api/src/modules/summary/entities/summary.entity.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 70db786 and 18f1059.
Files selected for processing (1)
  • apps/api/src/common/graphql/services/core.service.ts (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • apps/api/src/common/graphql/services/core.service.ts

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between 18f1059 and f0cc275.
Files selected for processing (2)
  • apps/api/Transcript Summarization.postman_collection.json (1 hunks)
  • apps/api/src/modules/summary/entities/summary.entity.ts (2 hunks)
Files not reviewed due to errors (1)
  • apps/api/Transcript Summarization.postman_collection.json (no review received)
Files skipped from review as they are similar to previous changes (1)
  • apps/api/src/modules/summary/entities/summary.entity.ts

@xixas
Copy link
Contributor

xixas commented May 11, 2024

@ramraut-osm Fix the example its still using job_id

@ramraut-osm
Copy link
Contributor Author

@ramraut-osm Fix the example its still using job_id

Updated

@ramraut-osm ramraut-osm merged commit 6eccb8e into main May 11, 2024
@ramraut-osm ramraut-osm deleted the REST-529 branch May 11, 2024 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ready for review Ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants