skrawcz commented on code in PR #666:
URL: https://github.com/apache/burr/pull/666#discussion_r3004383092


##########
burr/tracking/server/s3/backend.py:
##########
@@ -656,6 +709,104 @@ async def get_application_logs(
             application=graph_data,
         )
 
+    # BIP-0042: Event-driven tracking methods
+    async def _handle_s3_event(self, s3_key: str, event_time: 
datetime.datetime) -> None:
+        """Handle a single S3 event notification - index the file immediately.
+
+        :param s3_key: The S3 object key from the event
+        :param event_time: When the event occurred
+        """
+        try:
+            data_file = DataFile.from_path(s3_key, created_date=event_time)
+            # Path structure: 
data/{project}/yyyy/mm/dd/hh/minutes/pk/app_id/filename
+            project_name = s3_key.split("/")[1]
+
+            project = await Project.filter(name=project_name).first()
+            if project is None:
+                logger.info(f"Creating project {project_name} from S3 event")
+                project = await Project.create(
+                    name=project_name,
+                    uri=None,
+                    created_at=event_time,
+                    indexed_at=event_time,
+                    updated_at=event_time,
+                )
+
+            all_applications = await 
self._ensure_applications_exist([data_file], project)
+            await self._update_all_applications(all_applications, [data_file])
+            await self.update_log_files([data_file], all_applications)
+
+            logger.info(f"Indexed S3 event: {s3_key}")
+        except Exception as e:
+            logger.error(f"Failed to handle S3 event {s3_key}: {e}")
+

Review Comment:
   @vaquarkhan bump on this.



-- 
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