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