-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/discourse null values #340
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
dags/analyzer_helper/discourse/transform_raw_members.py (2)
51-51
: Consider adding date format validationWhile the null check is good, consider adding validation for the date format to handle malformed dates gracefully.
- "joined_at": ( - self.converter.from_date_string(joined_at) if joined_at else None - ), + "joined_at": ( + self.converter.from_date_string(joined_at) + if joined_at and self._is_valid_date_format(joined_at) + else None + ),You'll need to add a helper method:
def _is_valid_date_format(self, date_string: str) -> bool: try: self.converter.from_date_string(date_string) return True except ValueError: logging.warning(f"Invalid date format: {date_string}") return FalseAlso applies to: 57-59
61-61
: Consider case-insensitive comparison for "null"While changing from
is not
to!=
is correct for string comparison, consider handling different cases of "null" for more robust validation.- "name": member["name"] if member["name"] != "null" else None, + "name": member["name"] if member["name"].lower() != "null" else None,dags/analyzer_helper/tests/unit/test_discourse_transform_raw_members.py (1)
49-78
: Enhance test coverage with additional edge casesWhile the test covers the basic "null" case, consider adding tests for:
- Different cases of "null" (e.g., "NULL", "Null")
- Missing name field in the input
- None value for name
Here's a suggested additional test:
def test_transform_member_name_edge_cases(self): """Tests various edge cases for member name handling""" test_cases = [ {"name": "NULL", "expected": None}, # Upper case {"name": "Null", "expected": None}, # Mixed case {"name": None, "expected": None}, # None value ] base_member = { "id": 85149, "joined_at": "2023-07-02", "isBot": False, "username": "memberUser1", "avatar": "/path1/{size}/endpoint", } for case in test_cases: with self.subTest(name=case["name"]): member = {**base_member, "name": case["name"]} result = self.transformer.transform([member])[0] self.assertEqual(result["options"]["name"], case["expected"])
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
dags/analyzer_helper/discourse/transform_raw_members.py
(1 hunks)dags/analyzer_helper/tests/unit/test_discourse_transform_raw_members.py
(1 hunks)
🔇 Additional comments (1)
dags/analyzer_helper/discourse/transform_raw_members.py (1)
41-43
: LGTM: Improved null-safety for avatar handling
The added null check before calling startswith
prevents potential NullPointerException. This is a good defensive programming practice.
Summary by CodeRabbit
New Features
avatar_template
andjoined_at
fields.Bug Fixes
name
field to prevent issues with the string "null".Tests