From dd0c2c3db53d836fb56db05e1e760c4c046cbbd5 Mon Sep 17 00:00:00 2001 From: Jareth Whitney Date: Fri, 10 Nov 2023 11:34:11 -0800 Subject: [PATCH] feature/deseng415: Added recording of date with feedback submission and displaying the data on admin side. --- CHANGELOG.MD | 6 +++++ docs/MET_database_ERD.md | 1 + ...added_url_path_column_to_feedback_table.py | 27 +++++++++++++++++++ met-api/src/met_api/models/feedback.py | 2 ++ met-api/src/met_api/schemas/feedback.py | 1 + .../src/met_api/schemas/schemas/feedback.json | 12 ++++++++- met-web/package.json | 2 +- .../feedback/FeedbackModal/index.tsx | 4 +-- met-web/src/components/feedback/listing.tsx | 8 ++++++ met-web/src/models/feedback.ts | 9 +++++++ met-web/src/services/feedbackService/types.ts | 3 +++ .../feedback/feedbackListing.test.tsx | 2 ++ .../feedback/feedbackModal.test.tsx | 1 + tools/postman/MET.postman_collection.json | 9 ++++++- 14 files changed, 82 insertions(+), 5 deletions(-) create mode 100644 met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py diff --git a/CHANGELOG.MD b/CHANGELOG.MD index ef2960a46..efcf83693 100644 --- a/CHANGELOG.MD +++ b/CHANGELOG.MD @@ -2,11 +2,17 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](https://semver.org/). +## v1.1.0 - 2023-10-26 + +> **Feature**: Started logging source url path with feedback submission. Viewable in dashboard. [🎟️DESENG-415](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-415) + ## v1.0.1 - 2023-10-26 > **Bug Fix**: Upgraded BC-Sans font to newest version. [🎟️DESENG-413](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-413) + > **Bug Fix**: Engagements will now open in the same browser window/tab, not a new one. [🎟️DESENG-421](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-421) + > **Bug Fix**: Update sample .env files - [🎟️DESENG-414](https://apps.itsm.gov.bc.ca/jira/browse/DESENG-414) >- Sample .env files have been updated to reflect the current state of the project. >- *Breaking*: Keycloak URLs and resources now point to the BC Government's SSO service when using `sample.env` as a baseline diff --git a/docs/MET_database_ERD.md b/docs/MET_database_ERD.md index e1ea22876..db6470461 100644 --- a/docs/MET_database_ERD.md +++ b/docs/MET_database_ERD.md @@ -286,6 +286,7 @@ erDiagram type rating type comment_type string comment + string submission_path type source timestamp created_date timestamp updated_date diff --git a/met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py b/met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py new file mode 100644 index 000000000..138f01cf5 --- /dev/null +++ b/met-api/migrations/versions/02ff8ecc6b91_added_url_path_column_to_feedback_table.py @@ -0,0 +1,27 @@ +"""Added URL path column to feedback table. + +Revision ID: 02ff8ecc6b91 +Revises: 25e6609cb4db +Create Date: 2023-11-10 10:33:06.780841 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '02ff8ecc6b91' +down_revision = '25e6609cb4db' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('feedback', sa.Column('submission_path', sa.String())) + # ### end Alembic commands ### + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('feedback', 'submission_path') + # ### end Alembic commands ### diff --git a/met-api/src/met_api/models/feedback.py b/met-api/src/met_api/models/feedback.py index 62aeb1a22..38655b488 100644 --- a/met-api/src/met_api/models/feedback.py +++ b/met-api/src/met_api/models/feedback.py @@ -24,6 +24,7 @@ class Feedback(BaseModel): rating = db.Column(db.Enum(RatingType), nullable=True) comment_type = db.Column(db.Enum(CommentType), nullable=True) comment = db.Column(db.Text, nullable=True) + submission_path = db.Column(db.Text, nullable=True) source = db.Column(db.Enum(FeedbackSourceType), nullable=True) tenant_id = db.Column( db.Integer, db.ForeignKey('tenant.id'), nullable=True) @@ -65,6 +66,7 @@ def create_feedback(feedback): new_feedback = Feedback( status=feedback.get('status', None), comment=feedback.get('comment', None), + submission_path=feedback.get('submission_path', None), created_date=datetime.utcnow(), rating=feedback.get('rating'), comment_type=feedback.get('comment_type', None), diff --git a/met-api/src/met_api/schemas/feedback.py b/met-api/src/met_api/schemas/feedback.py index 24a8fcaa1..87d7d50c6 100644 --- a/met-api/src/met_api/schemas/feedback.py +++ b/met-api/src/met_api/schemas/feedback.py @@ -16,6 +16,7 @@ class Meta: # pylint: disable=too-few-public-methods id = fields.Int(data_key='id') comment = fields.Str(data_key='comment') + submission_path = fields.Str(data_key='submission_path') created_date = fields.DateTime(data_key='created_date') status = EnumField(FeedbackStatusType, by_value=True) rating = EnumField(RatingType, by_value=True) diff --git a/met-api/src/met_api/schemas/schemas/feedback.json b/met-api/src/met_api/schemas/schemas/feedback.json index 0acee4a7a..78642337d 100644 --- a/met-api/src/met_api/schemas/schemas/feedback.json +++ b/met-api/src/met_api/schemas/schemas/feedback.json @@ -9,7 +9,8 @@ { "rating": 1, "comment_type": "2", - "comment": "Custom comment" + "comment": "Custom comment", + "submission_path": "/gdx/" } ], "required": [ @@ -46,6 +47,15 @@ "examples": [ "A comment example" ] + }, + "submission_path": { + "$id": "#/properties/verification_token", + "type": "string", + "title": "Path", + "description": "The path that the feedback was submitted from.", + "examples": [ + "/gdx/" + ] } } } \ No newline at end of file diff --git a/met-web/package.json b/met-web/package.json index 356336890..24cf52945 100644 --- a/met-web/package.json +++ b/met-web/package.json @@ -1,6 +1,6 @@ { "name": "client", - "version": "1.0.1", + "version": "1.1.0", "private": true, "dependencies": { "@arcgis/core": "^4.26.5", diff --git a/met-web/src/components/feedback/FeedbackModal/index.tsx b/met-web/src/components/feedback/FeedbackModal/index.tsx index 5d0486d6e..7dab5f805 100644 --- a/met-web/src/components/feedback/FeedbackModal/index.tsx +++ b/met-web/src/components/feedback/FeedbackModal/index.tsx @@ -15,7 +15,7 @@ import CloseIcon from '@mui/icons-material/Close'; import { ReactComponent as CheckIcon } from 'assets/images/check.svg'; import { useState } from 'react'; import { MetBody, MetHeader3, MetLabel, modalStyle, PrimaryButton, MetDisclaimer } from '../../common'; -import { CommentTypeEnum, createDefaultFeedback, RatingTypeEnum } from 'models/feedback'; +import { CommentTypeEnum, createDefaultFeedback, setFeedbackPath, RatingTypeEnum } from 'models/feedback'; import { Else, If, Then, When } from 'react-if'; import { CommentTypeButton, StyledRating } from './styledComponents'; import { createFeedback } from 'services/feedbackService'; @@ -29,8 +29,8 @@ import SentimentVeryDissatisfiedIcon from '@mui/icons-material/SentimentVeryDiss export const FeedbackModal = () => { const [isSubmitted, setIsSubmitted] = useState(false); const [isOpen, setIsOpen] = useState(false); - const [feedbackFormData, setFeedbackFormData] = useState(createDefaultFeedback()); const [isSaving, setIsSaving] = useState(false); + const [feedbackFormData, setFeedbackFormData] = useState(setFeedbackPath(createDefaultFeedback())); const { comment, rating, comment_type } = feedbackFormData; const dispatch = useAppDispatch(); diff --git a/met-web/src/components/feedback/listing.tsx b/met-web/src/components/feedback/listing.tsx index ff3d987fa..c9f0c2d83 100644 --- a/met-web/src/components/feedback/listing.tsx +++ b/met-web/src/components/feedback/listing.tsx @@ -98,6 +98,14 @@ const FeedbackListing = () => { allowSort: true, renderCell: (row: Feedback) => SourceTypeEnum[row.source ?? 0].toString(), }, + { + key: 'submission_path', + numeric: false, + disablePadding: false, + label: 'Path', + allowSort: true, + renderCell: (row: Feedback) => row.submission_path, + }, { key: 'comment_type', numeric: false, diff --git a/met-web/src/models/feedback.ts b/met-web/src/models/feedback.ts index 3f389fb4c..89f5c92fd 100644 --- a/met-web/src/models/feedback.ts +++ b/met-web/src/models/feedback.ts @@ -6,6 +6,7 @@ export interface Feedback { comment_type: CommentTypeEnum; source: SourceTypeEnum; status: FeedbackStatusEnum; + submission_path: string; } export enum FeedbackStatusEnum { @@ -38,5 +39,13 @@ export const createDefaultFeedback = (): Feedback => { created_date: '', source: SourceTypeEnum.Public, status: FeedbackStatusEnum.NotReviewed, + submission_path: '', + }; +}; + +export const setFeedbackPath = (existingFeedback: Feedback): Feedback => { + return { + ...existingFeedback, + submission_path: window.location.pathname, }; }; diff --git a/met-web/src/services/feedbackService/types.ts b/met-web/src/services/feedbackService/types.ts index 2d47f1fd0..f90b9cf5b 100644 --- a/met-web/src/services/feedbackService/types.ts +++ b/met-web/src/services/feedbackService/types.ts @@ -1,4 +1,5 @@ import { FeedbackStatusEnum } from 'models/feedback'; +import { string } from 'yup'; export interface GetFeedbackRequest { page?: number; @@ -14,6 +15,7 @@ export interface PostFeedbackRequest { comment_type: number; comment: string; status: FeedbackStatusEnum; + submission_path: string; } export interface UpdateFeedbackRequest { @@ -21,4 +23,5 @@ export interface UpdateFeedbackRequest { comment_type?: number; comment?: string; status?: FeedbackStatusEnum; + submission_path?: string; } diff --git a/met-web/tests/unit/components/feedback/feedbackListing.test.tsx b/met-web/tests/unit/components/feedback/feedbackListing.test.tsx index 9ddb928f6..1df91fcbf 100644 --- a/met-web/tests/unit/components/feedback/feedbackListing.test.tsx +++ b/met-web/tests/unit/components/feedback/feedbackListing.test.tsx @@ -13,6 +13,7 @@ const mockFeedbackOne = { ...createDefaultFeedback(), rating: 2, comment: 'Feedback One', + submission_path: '/gdx/', comment_type: CommentTypeEnum.None, created_date: '2022-09-17 10:00:00', source: SourceTypeEnum.Public, @@ -22,6 +23,7 @@ const mockFeedbackTwo = { ...createDefaultFeedback(), rating: 1, comment: 'Feedback Two', + submission_path: '/eao/', comment_type: CommentTypeEnum.None, created_date: '2022-09-19 10:00:00', source: SourceTypeEnum.Public, diff --git a/met-web/tests/unit/components/feedback/feedbackModal.test.tsx b/met-web/tests/unit/components/feedback/feedbackModal.test.tsx index 10da3d199..221ec18a2 100644 --- a/met-web/tests/unit/components/feedback/feedbackModal.test.tsx +++ b/met-web/tests/unit/components/feedback/feedbackModal.test.tsx @@ -53,6 +53,7 @@ describe('Feedback modal tests', () => { status: FeedbackStatusEnum.NotReviewed, comment_type: CommentTypeEnum.None, comment: '', + submission_path: '', rating: 1, created_date: '', source: SourceTypeEnum.Public, diff --git a/tools/postman/MET.postman_collection.json b/tools/postman/MET.postman_collection.json index 025e3abda..b5f53845a 100644 --- a/tools/postman/MET.postman_collection.json +++ b/tools/postman/MET.postman_collection.json @@ -758,6 +758,7 @@ " var jsonData = pm.response.json().result;\r", " pm.expect(jsonData.rating).to.exist\r", " pm.expect(jsonData.comment).to.exist\r", + " pm.expect(jsonData.submission_path).to.exist\r", " pm.expect(jsonData.comment_type).to.exist\r", " pm.expect(jsonData.created_date).to.exist\r", " pm.expect(jsonData.source).to.exist\r", @@ -813,7 +814,7 @@ "header": [], "body": { "mode": "raw", - "raw": "{\r\n \"rating\": {{FEEDBACK_RATING}},\r\n \"comment\": \"{{FEEDBACK_COMMENT}}\",\r\n \"comment_type\":{{FEEDBACK_COMMENT_TYPE}},\r\n \"created_date\": \"{{FEEDBACK_CREATED_DATE}}\",\r\n \"source\": {{FEEDBACK_SOURCE}}\r\n}", + "raw": "{\r\n \"rating\": {{FEEDBACK_RATING}},\r\n \"comment\": \"{{FEEDBACK_COMMENT}}\",\r\n \"submission_path\": \"{{FEEDBACK_SUBMISSION_PATH}}\",\r\n \"comment_type\":{{FEEDBACK_COMMENT_TYPE}},\r\n \"created_date\": \"{{FEEDBACK_CREATED_DATE}}\",\r\n \"source\": {{FEEDBACK_SOURCE}}\r\n}", "options": { "raw": { "language": "json" @@ -858,6 +859,7 @@ " for (var i=0; i