Skip to content

Commit e8f07b0

Browse files
authored
Merge pull request #488 from Jdubrick/add-timestamp-feedback-status
add timestamp to feedback status updates
2 parents 2212d7a + 1b6b850 commit e8f07b0

4 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎docs/openapi.json‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,11 +1534,12 @@
15341534
"status"
15351535
],
15361536
"title": "FeedbackStatusUpdateResponse",
1537-
"description": "Model representing a response to a feedback status update request.\n\nAttributes:\n status: The previous and current status of the service and who updated it.\n\nExample:\n ```python\n status_response = StatusResponse(\n status={\n \"previous_status\": true,\n \"updated_status\": false,\n \"updated_by\": \"user/test\"\n },\n )\n ```",
1537+
"description": "Model representing a response to a feedback status update request.\n\nAttributes:\n status: The previous and current status of the service and who updated it.\n\nExample:\n ```python\n status_response = StatusResponse(\n status={\n \"previous_status\": true,\n \"updated_status\": false,\n \"updated_by\": \"user/test\",\n \"timestamp\": \"2023-03-15 12:34:56\"\n },\n )\n ```",
15381538
"examples": [
15391539
{
15401540
"status": {
15411541
"previous_status": true,
1542+
"timestamp": "2023-03-15 12:34:56",
15421543
"updated_by": "user/test",
15431544
"updated_status": false
15441545
}
@@ -1659,7 +1660,8 @@
16591660
"enum": [
16601661
"equals",
16611662
"contains",
1662-
"in"
1663+
"in",
1664+
"match"
16631665
],
16641666
"title": "JsonPathOperator",
16651667
"description": "Supported operators for JSONPath evaluation."

‎src/app/endpoints/feedback.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,13 @@ async def update_feedback_status(
208208
updated_status = (
209209
configuration.user_data_collection_configuration.feedback_enabled
210210
)
211+
current_time = str(datetime.now(UTC))
211212

212213
return FeedbackStatusUpdateResponse(
213214
status={
214215
"previous_status": previous_status,
215216
"updated_status": updated_status,
216217
"updated_by": user_id,
218+
"timestamp": current_time,
217219
}
218220
)

‎src/models/responses.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ class FeedbackStatusUpdateResponse(BaseModel):
593593
status={
594594
"previous_status": true,
595595
"updated_status": false,
596-
"updated_by": "user/test"
596+
"updated_by": "user/test",
597+
"timestamp": "2023-03-15 12:34:56"
597598
},
598599
)
599600
```
@@ -610,6 +611,7 @@ class FeedbackStatusUpdateResponse(BaseModel):
610611
"previous_status": True,
611612
"updated_status": False,
612613
"updated_by": "user/test",
614+
"timestamp": "2023-03-15 12:34:56",
613615
},
614616
}
615617
]

‎tests/unit/app/endpoints/test_feedback.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def test_store_feedback_on_io_error(mocker, feedback_request_data):
197197
store_feedback(user_id, feedback_request_data)
198198

199199

200-
async def test_update_feedback_status_different():
200+
async def test_update_feedback_status_different(mocker):
201201
"""Test that update_feedback_status returns the correct status with an update."""
202202
configuration.user_data_collection_configuration.feedback_enabled = True
203203

@@ -210,10 +210,11 @@ async def test_update_feedback_status_different():
210210
"previous_status": True,
211211
"updated_status": False,
212212
"updated_by": "test_user_id",
213+
"timestamp": mocker.ANY,
213214
}
214215

215216

216-
async def test_update_feedback_status_no_change():
217+
async def test_update_feedback_status_no_change(mocker):
217218
"""Test that update_feedback_status returns the correct status with no update."""
218219
configuration.user_data_collection_configuration.feedback_enabled = True
219220

@@ -226,4 +227,5 @@ async def test_update_feedback_status_no_change():
226227
"previous_status": True,
227228
"updated_status": True,
228229
"updated_by": "test_user_id",
230+
"timestamp": mocker.ANY,
229231
}

0 commit comments

Comments
 (0)