Skip to content

Commit

Permalink
Stop reduce anti-pattern contagion 2 (#22462)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Missed a few spots in #22454

## How I Tested These Changes

load the app and visit various pages without crashing + ts / jest
  • Loading branch information
salazarm authored Jun 11, 2024
1 parent 8ca177f commit f36892e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ export const TokenizingField = ({
// Suggest providers (eg: `pipeline:`) so users can discover the search space

suggestionsArr = filteredSuggestionProviders
.reduce(
(accum: Suggestion[], s) =>
s.token ? [...accum, {text: `${s.token}:`, final: false}] : accum,
[],
)
.reduce((accum: Suggestion[], s) => {
if (s.token) {
accum.push({text: `${s.token}:`, final: false});
}
return accum;
}, [])
.filter((s) => matchesTypedText(lastPart, s));

// Suggest value completions so users can type "airline_" without the "pipeline"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ const AssetLineageInfoElement = ({
<Box flex={{display: 'inline-flex', alignItems: 'center'}}>
{lineage_info.assetKey.path
.map((p, i) => <span key={i}>{p}</span>)
.reduce(
(accum, curr, ii) => [
...accum,
ii > 0 ? (
<React.Fragment key={`${ii}-space`}>&nbsp;{'>'}&nbsp;</React.Fragment>
) : null,
curr,
],
[] as React.ReactNode[],
)}
.reduce((accum, curr, ii) => {
if (ii > 0) {
accum.push(
<React.Fragment key={`${ii}-space`}>&nbsp;{'>'}&nbsp;</React.Fragment>,
);
}
accum.push(curr);
return accum;
}, [] as React.ReactNode[])}
</Box>
</Link>
</Tooltip>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@ export const AssetLink = (props: {
const linkUrl = url ? url : assetDetailsPathForKey({path});
const assetPath =
path
.reduce((accum, elem, ii) => [...accum, ii > 0 ? ' / ' : '', elem], [] as string[])
.reduce((accum, elem, ii) => {
if (ii > 0) {
accum.push(' / ');
}
accum.push(elem);
return accum;
}, [] as string[])

.join('') + (isGroup ? '/' : '');

return (
Expand Down
3 changes: 2 additions & 1 deletion js_modules/dagster-ui/packages/ui-core/src/runs/Run.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ const RunWithData = ({
? logsFilter.logQuery
.filter((v) => v.token && v.token === 'query')
.reduce((accum, v) => {
return [...accum, ...filterByQuery(runtimeGraph, v.value).all.map((n) => n.name)];
accum.push(...filterByQuery(runtimeGraph, v.value).all.map((n) => n.name));
return accum;
}, [] as string[])
: [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ const primaryDataToSearchResults = (input: {data?: SearchPrimaryQuery}) => {

const repoLocation = locationEntry.locationOrLoadError;
const repos = repoLocation.repositories;
return [
...accum,
accum.push(
...repos.reduce((inner, repo) => {
const {
name: repoName,
Expand Down Expand Up @@ -175,7 +174,8 @@ const primaryDataToSearchResults = (input: {data?: SearchPrimaryQuery}) => {
...allResources,
];
}, [] as SearchResult[]),
];
);
return accum;
}, [] as SearchResult[]);

return allEntries;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ export const WorkspaceProvider = ({children}: {children: React.ReactNode}) => {
}
const repositoryLocation = locationEntry.locationOrLoadError;
const reposForLocation = repoLocationToRepos(repositoryLocation);
return [...accum, ...reposForLocation];
accum.push(...reposForLocation);
return accum;
}, [] as DagsterRepoOption[]),

// Sort by repo location, then by repo
Expand Down

2 comments on commit f36892e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-storybook ready!

✅ Preview
https://dagit-storybook-cpipkolny-elementl.vercel.app

Built with commit f36892e.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-npbrahmi1-elementl.vercel.app

Built with commit f36892e.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.