pierrejeambrun commented on code in PR #54377:
URL: https://github.com/apache/airflow/pull/54377#discussion_r2313977489


##########
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##########
@@ -217,8 +220,23 @@ export const useLogs = (
     },
   );
 
+  const truncatedData = useMemo(() => {
+    if (!data?.content || typeof limit !== "number" || limit <= 0) {
+      return data;
+    }
+
+    const streamingContent = parseStreamingLogContent(data);
+    const truncatedContent =
+      streamingContent.length > limit ? streamingContent.slice(-limit) : 
streamingContent;
+

Review Comment:
   Add a comment explaining why this is done in the front-end. (Backend does 
not support yet pagination / limits on logs reading endpoint)



##########
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##########
@@ -217,8 +220,23 @@ export const useLogs = (
     },
   );
 
+  const truncatedData = useMemo(() => {
+    if (!data?.content || typeof limit !== "number" || limit <= 0) {
+      return data;
+    }
+
+    const streamingContent = parseStreamingLogContent(data);
+    const truncatedContent =
+      streamingContent.length > limit ? streamingContent.slice(-limit) : 
streamingContent;
+
+    return {
+      ...data,
+      content: truncatedContent,
+    };
+  }, [data, limit]);
+
   const parsedData = parseLogs({
-    data: parseStreamingLogContent(data),
+    data: parseStreamingLogContent(typeof limit === "number" && limit > 0 ? 
truncatedData : data),

Review Comment:
   `truncatedData` already holds that logic.
   
   ```suggestion
       data: parseStreamingLogContent(truncatedData),
   ```



##########
airflow-core/src/airflow/ui/src/queries/useLogs.tsx:
##########
@@ -217,8 +220,23 @@ export const useLogs = (
     },
   );
 
+  const truncatedData = useMemo(() => {
+    if (!data?.content || typeof limit !== "number" || limit <= 0) {

Review Comment:
   ```suggestion
       if (!data?.content || limit === undefined || limit <= 0) {
   ```



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