Skip to content

Commit

Permalink
Merge pull request #128 from edx/rijuma/added-timestamp-to-history-re…
Browse files Browse the repository at this point in the history
…sponse

feat: Added timestamp to Learning Assistant History response
  • Loading branch information
rijuma authored Nov 7, 2024
2 parents 1d734a9 + 510303b commit 5c460d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions learning_assistant/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,19 @@ class MessageSerializer(serializers.Serializer): # pylint: disable=abstract-met

role = serializers.CharField(required=True)
content = serializers.CharField(required=True)
timestamp = serializers.DateTimeField(required=False, source='created')

class Meta:
"""
Serializer metadata.
"""

model = LearningAssistantMessage
fields = (
'role',
'content',
'timestamp',
)

def validate_role(self, value):
"""
Expand Down
1 change: 1 addition & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,4 @@ def test_learning_message_history_view_get(
actual_message = LearningAssistantMessage.objects.get(course_id=self.course_id)
self.assertEqual(data[0]['role'], actual_message.role)
self.assertEqual(data[0]['content'], actual_message.content)
self.assertEqual(data[0]['timestamp'], actual_message.created.isoformat())

0 comments on commit 5c460d4

Please sign in to comment.