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.
- Loading branch information
Showing
8 changed files
with
320 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
from event_sink_clickhouse.sinks.base_sink import ModelBaseSink, ItemSerializer | ||
|
||
class UserProfileSerializer(ItemSerializer): | ||
""" | ||
Serializer for user profile events | ||
""" | ||
def serialize_item(self, user_profile): | ||
return { | ||
"id": user_profile.id, | ||
"name": user_profile.name, | ||
"meta": user_profile.meta, | ||
"courseware": user_profile.courseware, | ||
"language": user_profile.language, | ||
"location": user_profile.location, | ||
"year_of_birth": user_profile.year_of_birth, | ||
"gender": user_profile.gender, | ||
"level_of_education": user_profile.level_of_education, | ||
"mailing_address": user_profile.mailing_address, | ||
"city": user_profile.city, | ||
"country": user_profile.country, | ||
"state": user_profile.state, | ||
"goals": user_profile.goals, | ||
"bio": user_profile.bio, | ||
"profile_image_uploaded_at": user_profile.profile_image_uploaded_at, | ||
"phone_number": user_profile.phone_number, | ||
} | ||
|
||
|
||
class UserProfileSink(ModelBaseSink): | ||
""" | ||
Sink for user profile events | ||
""" | ||
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", | ||
] | ||
unique_key= "id" | ||
clickhouse_table_name = "user_profile" | ||
timestamp_field = "time_last_dumped" | ||
name = "User Profile" | ||
serializer_class = UserProfileSerializer |
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,11 @@ | ||
from importlib import import_module | ||
|
||
from django.conf import settings | ||
|
||
|
||
def get_model(model_name): | ||
model_config = getattr(settings, "EVENT_SINK_CLICKHOUSE_MODEL_CONFIG").get(model_name) | ||
module = model_config["module"] | ||
model_name = model_config["model"] | ||
model = getattr(import_module(module), model_name) | ||
return model |
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