Skip to content

Commit

Permalink
fix: update ci-cd.yml and influxdb_client.py
Browse files Browse the repository at this point in the history
  • Loading branch information
MountainGod2 committed Aug 8, 2024
1 parent e3d6365 commit 42016d0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,6 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
type=latest
- name: Checkout repository
uses: actions/checkout@v4
Expand Down
32 changes: 1 addition & 31 deletions src/chaturbate_poller/influxdb_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,6 @@ def flatten_dict(
items.append((new_key, v))
return dict(items)

def format_data_for_storage(self, data: dict[str, Any]) -> dict[str, Any]:
"""Format data for InfluxDB storage with user-friendly structure.
Args:
data (dict[str, Any]): The data to format.
Returns:
dict[str, Any]: The formatted data.
"""
return {
"timestamp": data.get("timestamp"),
"event_type": data.get("event_type"),
"user": {
"username": data.get("user", {}).get("username", ""),
"broadcaster": data.get("user", {}).get("broadcaster", ""),
"in_fanclub": data.get("user", {}).get("in_fanclub", False),
"has_tokens": data.get("user", {}).get("has_tokens", False),
"is_mod": data.get("user", {}).get("is_mod", False),
"recent_tips": data.get("user", {}).get("recent_tips", ""),
"gender": data.get("user", {}).get("gender", ""),
"subgender": data.get("user", {}).get("subgender", ""),
},
"media": data.get("media"),
"tip": data.get("tip"),
"message": data.get("message"),
"subject": data.get("subject"),
"event_id": data.get("event_id"),
}

def write_event(self, measurement: str, data: dict[str, Any]) -> None:
"""Write event data to InfluxDB.
Expand All @@ -86,8 +57,7 @@ def write_event(self, measurement: str, data: dict[str, Any]) -> None:
data (dict[str, Any]): The event data.
"""
try:
formatted_data = self.format_data_for_storage(data)
flattened_data = self.flatten_dict(formatted_data)
flattened_data = self.flatten_dict(data)
point = Point(measurement)
for key, value in flattened_data.items():
point = point.field(key, value)
Expand Down

0 comments on commit 42016d0

Please sign in to comment.