Skip to content

Commit

Permalink
Refactor ActSectionSerializer to use SerializerMethodField for act an…
Browse files Browse the repository at this point in the history
…nouncement date
  • Loading branch information
miskibin committed Nov 2, 2024
1 parent 0b73424 commit 6ffd0c3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/views/vector_search.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from django.db.models import F
from django.core.cache import cache
from rest_framework.views import APIView
Expand All @@ -16,7 +17,7 @@
class ActSectionSerializer(serializers.ModelSerializer):
act_url = serializers.SerializerMethodField()
act_title = serializers.CharField(source="act.title")
act_announcement_date = serializers.DateTimeField(source="act.announcementDate")
act_announcement_date = serializers.SerializerMethodField()
similarity_score = serializers.FloatField()

class Meta:
Expand All @@ -34,6 +35,9 @@ class Meta:
def get_act_url(self, obj: ActSection):
return obj.act.url

def get_act_announcement_date(self, obj: ActSection):
return str(obj.act.announcementDate)


class VectorSearchView(APIView):
CACHE_TIMEOUT = 3600
Expand Down

0 comments on commit 6ffd0c3

Please sign in to comment.