You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "gdivya6028 (via GitHub)" <gi...@apache.org> on 2026/05/05 05:11:00 UTC

Re: [PR] Allow search and filter by tags in dag run table #19197 [airflow]

gdivya6028 commented on code in PR #66017:
URL: https://github.com/apache/airflow/pull/66017#discussion_r3186156939


##########
airflow-core/src/airflow/ui/src/pages/DagRuns.tsx:
##########
@@ -228,15 +233,73 @@ export const DagRuns = () => {
   const durationGte = searchParams.get(DURATION_GTE_PARAM);
   const durationLte = searchParams.get(DURATION_LTE_PARAM);
   const confContains = searchParams.get(CONF_CONTAINS_PARAM);
+  const dagTag = searchParams.get(DAG_TAG);
   const partitionKeyPattern = searchParams.get(PARTITION_KEY_PATTERN_PARAM);
 
   const refetchInterval = useAutoRefresh({});
+  const { data: dagsData } = useQuery({
+    enabled: dagTag !== null && dagTag !== "",
+    queryFn: () =>
+      DagService.getDags({
+        excludeStale: true,
+        lastDagRunState: "success",
+        limit: 50,
+        tags: dagTag !== null && dagTag !== "" ? [dagTag] : undefined,
+        tagsMatchMode: "any",
+      }),
+    queryKey: ["dags", dagTag],
+  });
+
+  // ... (Keep your existing search param extractions here)
+  const filteredDagIds = React.useMemo(() => {
+    if (!dagsData?.dags) {
+      return [];
+    }
+
+    return dagsData.dags.map((dag: { dag_id: string }) => dag.dag_id);
+  }, [dagsData]);
+
+  // 2. Logic to calculate targetDagId
+  const targetDagId = React.useMemo(() => {
+    if (dagId !== "") {
+      return dagId; // Specific DAG page
+    }
+
+    if (dagTag !== null && dagTag !== "" && filteredDagIds.length === 0) {
+      return "~"; // No matches found
+    }
+
+    // If multiple IDs, use global wildcard "~"
+    if (filteredDagIds.length > 1) {
+      return "~";
+    }
+
+    // If exactly one, use it directly
+    if (filteredDagIds.length === 1) {
+      return filteredDagIds[0];
+    }
+
+    // No tag filter active
+    return "~";
+  }, [dagId, dagTag, filteredDagIds]);
+
+  // Create the regex pattern
+  const multiDagPattern = React.useMemo(() => {
+    // Only use pattern if we have multiple IDs and no explicit dagId
+    if (dagId === "" && filteredDagIds.length > 1) {
+      return filteredDagIds.join("|");
+    }

Review Comment:
   working on the changes



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org