This repository has been archived by the owner on Apr 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use django serializer for sink serialization
- Loading branch information
Showing
14 changed files
with
143 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from rest_framework import serializers | ||
|
||
import uuid | ||
from django.utils import timezone | ||
|
||
from event_sink_clickhouse.utils import get_model | ||
|
||
|
||
class BaseSinkSerializer(serializers.Serializer): | ||
dump_id = serializers.SerializerMethodField() | ||
dump_timestamp = serializers.SerializerMethodField() | ||
|
||
class Meta: | ||
fields = [ | ||
"dump_id", | ||
"dump_timestamp", | ||
] | ||
|
||
def get_dump_id(self, instance): | ||
return uuid.uuid4() | ||
|
||
def get_dump_timestamp(self, instance): | ||
return timezone.now() | ||
|
||
|
||
class UserProfileSerializer(BaseSinkSerializer, serializers.ModelSerializer): | ||
class Meta: | ||
model = get_model("user_profile") | ||
fields = [ | ||
"id", | ||
"name", | ||
"meta", | ||
"courseware", | ||
"language", | ||
"location", | ||
"year_of_birth", | ||
"gender", | ||
"level_of_education", | ||
"mailing_address", | ||
"city", | ||
"country", | ||
"state", | ||
"goals", | ||
"bio", | ||
"profile_image_uploaded_at", | ||
"phone_number", | ||
"dump_id", | ||
"dump_timestamp", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.