Skip to content

Commit

Permalink
Add try_number to extra links query (apache#35317)
Browse files Browse the repository at this point in the history
* Add try_number to extra links query

Add try_number to extra links query

* Do not include try_number in uri if undefined
  • Loading branch information
vchiapaikeo authored Nov 16, 2023
1 parent 9877f36 commit be6e2cd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
8 changes: 6 additions & 2 deletions airflow/www/static/js/api/useExtraLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,23 @@ export default function useExtraLinks({
executionDate,
mapIndex,
extraLinks,
tryNumber,
}: {
dagId: string;
taskId: string;
executionDate: string;
mapIndex?: number | undefined;
extraLinks: string[];
tryNumber?: number | undefined;
}) {
return useQuery(
["extraLinks", dagId, taskId, executionDate, mapIndex],
["extraLinks", dagId, taskId, executionDate, mapIndex, tryNumber],
async () => {
const data = await Promise.all(
extraLinks.map(async (link) => {
const definedMapIndex = mapIndex ?? -1;
const tryNumberParam =
tryNumber !== undefined ? `&try_number=${tryNumber}` : "";
const url = `${extraLinksUrl}?task_id=${encodeURIComponent(
taskId
)}&dag_id=${encodeURIComponent(
Expand All @@ -55,7 +59,7 @@ export default function useExtraLinks({
executionDate
)}&link_name=${encodeURIComponent(
link
)}&map_index=${definedMapIndex}`;
)}&map_index=${definedMapIndex}${tryNumberParam}`;
try {
const datum = await axios.get<AxiosResponse, LinkData>(url);
return {
Expand Down
3 changes: 3 additions & 0 deletions airflow/www/static/js/dag/details/taskInstance/ExtraLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ interface Props {
executionDate: string;
mapIndex?: number | undefined;
extraLinks: string[];
tryNumber?: number | undefined;
}

const ExtraLinks = ({
Expand All @@ -36,13 +37,15 @@ const ExtraLinks = ({
executionDate,
mapIndex,
extraLinks,
tryNumber,
}: Props) => {
const { data: links } = useExtraLinks({
dagId,
taskId,
executionDate,
mapIndex,
extraLinks,
tryNumber,
});

if (!links?.length) return null;
Expand Down
2 changes: 2 additions & 0 deletions airflow/www/static/js/dag/details/taskInstance/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ const TaskInstance = ({ taskId, runId, mapIndex }: Props) => {
mapIndex={mapIndex}
executionDate={executionDate}
extraLinks={group?.extraLinks}
tryNumber={instance.tryNumber}
/>
)}
{!isMapped && group.extraLinks && (
Expand All @@ -114,6 +115,7 @@ const TaskInstance = ({ taskId, runId, mapIndex }: Props) => {
dagId={dagId}
executionDate={executionDate}
extraLinks={group?.extraLinks}
tryNumber={instance.tryNumber}
/>
)}
<Details instance={instance} group={group} dagId={dagId} />
Expand Down

0 comments on commit be6e2cd

Please sign in to comment.