Skip to content

Commit

Permalink
Feature/deseng415 (#2334)
Browse files Browse the repository at this point in the history
* feature/deseng415: Added recording of date with feedback submission and displaying the data on admin side.

* feature/deseng415: Fixed feedback schema, removed yup import, fixed change log date.
  • Loading branch information
jareth-whitney authored Nov 10, 2023
1 parent 236ef36 commit 579f775
Show file tree
Hide file tree
Showing 14 changed files with 81 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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-11-10

> **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
Expand Down
1 change: 1 addition & 0 deletions docs/MET_database_ERD.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ erDiagram
type rating
type comment_type
string comment
string submission_path
type source
timestamp created_date
timestamp updated_date
Expand Down
Original file line number Diff line number Diff line change
@@ -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 ###
2 changes: 2 additions & 0 deletions met-api/src/met_api/models/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions met-api/src/met_api/schemas/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion met-api/src/met_api/schemas/schemas/feedback.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
{
"rating": 1,
"comment_type": "2",
"comment": "Custom comment"
"comment": "Custom comment",
"submission_path": "/gdx/"
}
],
"required": [
Expand Down Expand Up @@ -46,6 +47,15 @@
"examples": [
"A comment example"
]
},
"submission_path": {
"$id": "#/properties/submission_path",
"type": "string",
"title": "Path",
"description": "The path that the feedback was submitted from.",
"examples": [
"/gdx/"
]
}
}
}
2 changes: 1 addition & 1 deletion met-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "client",
"version": "1.0.1",
"version": "1.1.0",
"private": true,
"dependencies": {
"@arcgis/core": "^4.26.5",
Expand Down
4 changes: 2 additions & 2 deletions met-web/src/components/feedback/FeedbackModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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();

Expand Down
8 changes: 8 additions & 0 deletions met-web/src/components/feedback/listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions met-web/src/models/feedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Feedback {
comment_type: CommentTypeEnum;
source: SourceTypeEnum;
status: FeedbackStatusEnum;
submission_path: string;
}

export enum FeedbackStatusEnum {
Expand Down Expand Up @@ -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,
};
};
2 changes: 2 additions & 0 deletions met-web/src/services/feedbackService/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ export interface PostFeedbackRequest {
comment_type: number;
comment: string;
status: FeedbackStatusEnum;
submission_path: string;
}

export interface UpdateFeedbackRequest {
rating?: number;
comment_type?: number;
comment?: string;
status?: FeedbackStatusEnum;
submission_path?: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 8 additions & 1 deletion tools/postman/MET.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -858,6 +859,7 @@
" for (var i=0; i<jsonData.items.length; i++) {\r",
" pm.expect(jsonData.items[i].rating).to.exist\r",
" pm.expect(jsonData.items[i].comment).to.exist\r",
" pm.expect(jsonData.items[i].submission_path).to.exist\r",
" pm.expect(jsonData.items[i].comment_type).to.exist\r",
" pm.expect(jsonData.items[i].created_date).to.exist\r",
" pm.expect(jsonData.items[i].source).to.exist\r",
Expand Down Expand Up @@ -1084,6 +1086,11 @@
"value": "US",
"type": "string"
},
{
"key": "FEEDBACK_SUBMISSION_PATH",
"value": "US",
"type": "string"
},
{
"key": "FEEDBACK_SOURCE",
"value": "",
Expand Down

0 comments on commit 579f775

Please sign in to comment.