Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop reduce anti-pattern contagion 2 #22462

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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