Skip to content

Commit

Permalink
refactor: unnecessary wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
motoki317 committed Jan 7, 2025
1 parent f42e134 commit b969133
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions dashboard/src/libs/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -183,19 +183,15 @@ export const useApplicationsFilter = (
includeNoApp: boolean,
sort: 'asc' | 'desc',
): RepoWithApp[] => {
const filteredReposByOrigin = () => {
return repos.filter((r) => origins.includes(repositoryURLToOrigin(r.url))) ?? []
}
const filteredApps = () => {
return apps.filter((a) => statuses.includes(applicationState(a))) ?? []
}
const filteredReposByOrigin = repos.filter((r) => origins.includes(repositoryURLToOrigin(r.url)))
const filteredApps = apps.filter((a) => statuses.includes(applicationState(a)))

const appsMap = {} as Record<string, Application[]>
for (const app of filteredApps()) {
for (const app of filteredApps) {
if (!appsMap[app.repositoryId]) appsMap[app.repositoryId] = []
appsMap[app.repositoryId].push(app)
}
const res = filteredReposByOrigin().reduce<RepoWithApp[]>((acc, repo) => {
const res = filteredReposByOrigin.reduce<RepoWithApp[]>((acc, repo) => {
if (!includeNoApp && !appsMap[repo.id]) return acc
acc.push({ repo, apps: appsMap[repo.id] || [] })
return acc
Expand Down

0 comments on commit b969133

Please sign in to comment.