Skip to content

Commit

Permalink
Merge pull request #293 from TogetherCrew/fix/291-discourse-inconsist…
Browse files Browse the repository at this point in the history
…ent-id

fix: updating all users in raw data not to have floating point!
  • Loading branch information
amindadgar authored Sep 25, 2024
2 parents b42a626 + fb365f5 commit 71d8e76
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions dags/analyzer_helper/discourse/transform_raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ def create_data_entry(

result = {
"author_id": str(
interaction_user
int(interaction_user)
if interaction_type == "reply"
else raw_data.get("author_id")
else int(raw_data.get("author_id"))
),
"text": raw_data["text"],
"date": self.converter.from_iso_format(raw_data.get("created_at")),
Expand All @@ -49,20 +49,20 @@ def create_data_entry(
{
"name": "reaction",
"type": "emitter",
"users_engaged_id": [str(raw_data["author_id"])],
"users_engaged_id": [str(int(raw_data["author_id"]))],
}
]
result["author_id"] = str(interaction_user)
result["author_id"] = str(int(interaction_user))
elif interaction_type == "reply":
result["actions"] = []
result["interactions"] = [
{
"name": "reply",
"type": "receiver",
"users_engaged_id": [str(raw_data["author_id"])],
"users_engaged_id": [str(int(raw_data["author_id"]))],
}
]
result["author_id"] = str(interaction_user)
result["author_id"] = str(int(interaction_user))
else:
if raw_data["reactions"]:
result["interactions"].append(
Expand All @@ -79,7 +79,9 @@ def create_data_entry(
{
"name": "reply",
"type": "emitter",
"users_engaged_id": [str(raw_data["replied_post_user_id"])],
"users_engaged_id": [
str(int(raw_data["replied_post_user_id"]))
],
}
)
result["actions"] = [{"name": "message", "type": "emitter"}]
Expand Down Expand Up @@ -108,7 +110,7 @@ def transform(self, raw_data: list) -> list:
self.create_data_entry(
entry,
interaction_type="reply",
interaction_user=entry["replied_post_user_id"],
interaction_user=int(entry["replied_post_user_id"]),
)
)
# TODO: Create entry for mentioned users
Expand Down

0 comments on commit 71d8e76

Please sign in to comment.