Skip to content

Commit

Permalink
refactor: move database things for website
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user authored and benfdking committed Sep 5, 2024
1 parent 5f34859 commit 7faa9c3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 18 deletions.
10 changes: 4 additions & 6 deletions js/packages/quary-extension-bus/src/databaseShared.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import { isErr, Ok, Result } from './result'
import { TableAddress } from '@quary/proto/quary/service/v1/table_address'
import {
CacheViewInformation,
CacheViewInformationPaths,
} from '@quary/proto/quary/service/v1/wasm_rust_rpc_calls'
import { Empty } from '@quary/proto/google/protobuf/empty'
import { DatabaseDependentSettings } from './config'
import { ServicesDatabase } from './database'

export const cacheViewBuilder = async (
databaseDependentSettings: DatabaseDependentSettings,
listViews: () => Promise<Result<Array<TableAddress>>>,
database: ServicesDatabase,
): Promise<Result<CacheViewInformation>> => {
if (databaseDependentSettings.lookForCacheViews) {
const tables = await listViews()
if (database.returnDatabaseConfiguration().lookForCacheViews) {
const tables = await database.listViews()
if (isErr(tables)) {
return tables
}
Expand Down
5 changes: 1 addition & 4 deletions js/packages/quary-extension/src/web/chartCustomEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,10 +448,7 @@ export class ChartEditorProvider
if (isErr(preInitSetupResult)) {
return handleError(preInitSetupResult.error, allAssets)
}
const cacheView = await cacheViewBuilder(
services.database.returnDatabaseConfiguration(),
services.database.listViews,
)
const cacheView = await cacheViewBuilder(services.database)
if (isErr(cacheView)) {
return handleError(cacheView.error, allAssets)
}
Expand Down
5 changes: 1 addition & 4 deletions js/packages/quary-extension/src/web/commandsDocumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ const getModelDetails = async ({
const table = !isErr(modelTableDetails)
? (modelTableDetails.value.table ?? null)
: null
const cacheViewInformation = await cacheViewBuilder(
services.database.returnDatabaseConfiguration(),
services.database.listViews,
)
const cacheViewInformation = await cacheViewBuilder(services.database)
if (isErr(cacheViewInformation)) {
return cacheViewInformation
}
Expand Down
5 changes: 1 addition & 4 deletions js/packages/quary-extension/src/web/commandsExecuteSQL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ const getModelDetails = async ({
})
}

const cacheViewInformation = await cacheViewBuilder(
services.database.returnDatabaseConfiguration(),
services.database.listViews,
)
const cacheViewInformation = await cacheViewBuilder(services.database)
if (isErr(cacheViewInformation)) {
return cacheViewInformation
}
Expand Down

0 comments on commit 7faa9c3

Please sign in to comment.