1
0
Fork 0
mirror of synced 2024-10-04 03:54:37 +13:00

Remove more usage of accumulators because they're evil

This commit is contained in:
Andrew Kingston 2023-08-25 16:53:45 +01:00
parent 6c38eb5a4c
commit 02d2f9d875

View file

@ -15,6 +15,8 @@
import {
tables as tablesStore,
queries as queriesStore,
viewsV2 as viewsV2Store,
views as viewsStore,
} from "stores/backend"
import { datasources, integrations } from "stores/backend"
import BindingBuilder from "components/integration/QueryBindingBuilder.svelte"
@ -39,32 +41,16 @@
tableId: m._id,
type: "table",
}))
$: viewsV1 = $tablesStore.list.reduce(
(acc, table) => [
...acc,
...Object.values(table.views || {})
.filter(view => view.version !== 2)
.map(view => ({
$: viewsV1 = $viewsStore.list.map(view => ({
...view,
label: view.name,
type: "view",
})),
],
[]
)
$: viewsV2 = $tablesStore.list.reduce(
(acc, table) => [
...acc,
...Object.values(table.views || {})
.filter(view => view.version === 2)
.map(view => ({
}))
$: viewsV2 = $viewsV2Store.list.map(view => ({
...view,
label: view.name,
type: "viewV2",
})),
],
[]
)
}))
$: views = [...(viewsV1 || []), ...(viewsV2 || [])]
$: queries = $queriesStore.list
.filter(q => showAllQueries || q.queryVerb === "read" || q.readable)