sarthaksin1857 commented on code in PR #131:
URL: https://github.com/apache/otava/pull/131#discussion_r2838397654


##########
otava/graphite.py:
##########
@@ -80,49 +79,28 @@ class GraphiteError(IOError):
 
 @dataclass
 class GraphiteEvent:
-    test_owner: str
-    test_name: str
-    run_id: str
-    status: str
-    start_time: datetime
-    pub_time: datetime
-    end_time: datetime
-    version: Optional[str]
-    branch: Optional[str]
-    commit: Optional[str]
-
-    def __init__(
-        self,
-        pub_time: int,
-        test_owner: str,
-        test_name: str,
-        run_id: str,
-        status: str,
-        start_time: int,
-        end_time: int,
-        version: Optional[str],
-        branch: Optional[str],
-        commit: Optional[str],
-    ):
-        self.test_owner = test_owner
-        self.test_name = test_name
-        self.run_id = run_id
-        self.status = status
-        self.start_time = parse_datetime(str(start_time))
-        self.pub_time = parse_datetime(str(pub_time))
-        self.end_time = parse_datetime(str(end_time))
-        if len(version) == 0 or version == "null":
-            self.version = None
-        else:
-            self.version = version
-        if len(branch) == 0 or branch == "null":
-            self.branch = None
+    test_owner: Optional[str] = "null"
+    test_name: Optional[str] = "null"
+    run_id: Optional[str] = "null"
+    status: Optional[str] = "null"
+    start_time: Optional[datetime] = None
+    pub_time: Optional[datetime] = None
+    end_time: Optional[datetime] = None
+    version: Optional[str] = "null"
+    branch: Optional[str] = "null"
+    commit: Optional[str] = "null"
+
+
+    def __post_init__(self):
+        # Ensure pub_time is always a datetime
+        if self.pub_time is None:
+            self.pub_time = datetime.now()
         else:
-            self.branch = branch
-        if len(commit) == 0 or commit == "null":
-            self.commit = None
-        else:
-            self.commit = commit
+            self.pub_time = parse_datetime(str(self.pub_time))
+
+        # Now safely parse start_time and end_time
+        self.start_time = parse_datetime(str(self.start_time)) if 
self.start_time else self.pub_time
+        self.end_time = parse_datetime(str(self.end_time)) if self.end_time 
else self.pub_time

Review Comment:
   Still deciding if start and end time need to be set. The api only return a 
single timestamp (publish time) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to