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

Xiao F Create way for owner to edit & update ChatGPT prompt text #603

Conversation

tsunami776
Copy link
Contributor

@tsunami776 tsunami776 commented Nov 10, 2023

Description

CleanShot 2023-11-10 at 11 19 59

Related PRS (if any):

This back-end PR is related to the #1510 front-end PR.

Main changes explained:

  • Create file src/models/dashBoardData.js for prompt text schema
  • Update multiple files in controller and router for get and update prompt

How to test:

  1. Check into current branch
  2. Make sure do npm run build and npm start to start the BE
  3. Made sure logged in as Owner user
  4. Copy Auth token from Right click -> Inspect -> Application -> Local storage -> http://localhost:3000 -> token
  5. Go to Postman -> Select 'GET' http://localhost:4500/api/dashboard/aiPrompt -> Headers -> put Key 'Authorization', Value 'the token you copied in step 4'
  6. Send GET request and check "aIPromptText": "xxxx" is returned
  7. Change GET to PUT
  8. Go to 'Body' -> Select 'raw' -> Type in { "aIPromptText": "Updated prompt" } -> Send PUT request -> Check if 'Successfully saved AI prompt.' is returned and use GET to check if prompt is changed

Screenshots or videos of changes:

Get.Update.Prompt.Test.mp4

Note:

N/A

@tsunami776 tsunami776 marked this pull request as ready for review November 15, 2023 16:09
@tsunami776 tsunami776 removed the Do Not Review Do not review or look at code without full context label Nov 15, 2023
@tsunami776 tsunami776 added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Nov 23, 2023
@this-journey
Copy link
Contributor

I'm getting an "Error 500 Internal Server Error" on my GET request
Screenshot 2023-11-30 at 12 47 38 PM (2)

@tsunami776
Copy link
Contributor Author

Hi @this-journey, from the error it gave, it looks like you are passing an argument to GET request. Sorry, I cannot reproduce the error. I tested the GET endpoint and it works for me.
CleanShot 2023-11-30 at 14 59 45
CleanShot 2023-11-30 at 15 00 24
CleanShot 2023-11-30 at 15 00 38

Copy link

@Alforoan Alforoan left a comment

Choose a reason for hiding this comment

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

As per my video, it doesn't seem like the message is being saved.

pr.review.603.mp4

@tsunami776
Copy link
Contributor Author

tsunami776 commented Dec 1, 2023

Hi @Alforoan, as in your video, you are using GET for updating the prompt, you should use PUT instead.

@tsunami776 tsunami776 dismissed Alforoan’s stale review December 1, 2023 07:20

Hi @Alforoan, as in your screenshot, you are using GET for updating the prompt, you should use PUT instead.

Copy link

@Alforoan Alforoan left a comment

Choose a reason for hiding this comment

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

It's working as intended. My previous comment was due to my own error. I also left a comment on pr#1510. Nice!

2023-12-01.10-23-04.mp4

@DragonSlayer2401
Copy link
Contributor

I used my owner account to test both the GET request and PUT request. It appears that the GET request is working as intended however the PUT request appears to be only partially working it returns the success message but it doesn't update the text. Please see the video below for more info:

2023-12-02.10-28-56.mov

@ptrpengdev
Copy link
Contributor

Tested with FE PR 1510. The codes work as expected.

@ZichanYang324 ZichanYang324 self-requested a review December 7, 2023 19:34
Copy link

@ZichanYang324 ZichanYang324 left a comment

Choose a reason for hiding this comment

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

Hi @tsunami776, I have used the Postman to test the GET and PUT for Aiprompt, and all the function works well.

(1) For the GET request, after pasting the token from the application, it can request the response as intended and the result is correct.
(2) For the PUT request, after sending the put request, it showed the "successfully saved AI prompt".

Two images for reference.

Screenshot 2023-12-07 at 14 34 17 Screenshot 2023-12-07 at 14 33 15

Copy link

@pika-chu11 pika-chu11 left a comment

Choose a reason for hiding this comment

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

Tested the PR and the comment left on the FrontEnd #1510

Copy link

@Alforoan Alforoan left a comment

Choose a reason for hiding this comment

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

See my comment on the FE pr.

Copy link

@ljrirene ljrirene left a comment

Choose a reason for hiding this comment

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

Hi XiaoFei, this works as expected! Good job!
postman
postman-2
postman-3

@chappdev2019
Copy link
Member

Tested the PR and the comment left on the FrontEnd 1510

Copy link
Contributor

@cvtqx cvtqx left a comment

Choose a reason for hiding this comment

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

Tested this PR and its FE PR and it works as described. I am able to update and save the prompt when logged in as owner.
See my comments for FE PR.

@Haoxiang310
Copy link

Haoxiang310 commented Jan 6, 2024

Got an "Error 500 Internal Server Error" error on my GET request.
backend3-PR#603

@one-community
Copy link
Member

Thank you all, merging!

@one-community one-community merged commit 13e5c48 into development Jan 6, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.