VasaChiranjeevi / ai-customer-feedback-analysis

The objective of this project is to build an AI-powered system to collect and analyze customer reviews for multiple companies, generating summaries and extracting common keywords using existing free AI models. The reviews and their respective analysis will be stored in a database, and summaries will be updated
0 stars 0 forks source link

fixed #23

Closed 01darshants closed 1 month ago

01darshants commented 1 month ago

Summary by Sourcery

Refactor the 'SubmitResponse' class to use Django's 'View' instead of 'APIView', enhance error handling in the JavaScript code for review submission, and fix the handling of the 'renderpage' parameter in the 'get_reviews' function.

Bug Fixes:

Enhancements:

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request implements changes to improve the review submission process and update the UI accordingly. The main changes include modifying the get_reviews function to optionally render a page, updating the SubmitResponse class to render the index template with updated context, and adjusting the client-side JavaScript to handle the review submission process more effectively.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Server
    participant Database
    Client->>Server: POST /submit_review
    Server->>Database: Save new review
    Server->>Database: Update summary
    Server->>Server: Generate updated context
    Server->>Client: Render index.html with updated context
    Client->>Client: Reset form fields
    Client->>Client: Display success message

File-Level Changes

Change Details Files
Modified get_reviews function to support optional page rendering
  • Added a new parameter 'renderpage' with a default value of False
  • Implemented conditional logic to return a dictionary of reviews and summary when renderpage is True
  • Kept the existing JsonResponse for API calls
SentimentAnalysis/analysis/views.py
Updated SubmitResponse class to render index template
  • Changed SubmitResponse from APIView to View
  • Modified the post method to render the index.html template with updated context
  • Removed the direct call to get_reviews and replaced it with context generation
SentimentAnalysis/analysis/views.py
Improved client-side review submission process
  • Updated the submitReview function to handle the response more effectively
  • Added error handling for review submission
  • Removed the reset of the company select dropdown
SentimentAnalysis/analysis/templates/index.html
Added new imports in views.py
  • Imported JsonResponse from django.http
  • Imported View from django.views
  • Imported get_object_or_404 and render from django.shortcuts
SentimentAnalysis/analysis/views.py

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).