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

feature: run generateExploreDiagram on selected explore only #97

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle.js.map

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions src/utils/LookmlDiagrammer/diagrammer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,26 @@ export function generateExploreDiagram(
export function generateModelDiagrams(
details: DetailedModel,
hiddenToggle: boolean,
displayFieldType: string
displayFieldType: string,
exploreName: string
) {
const modifiedDetails: DiagrammedModel[] = []
details?.explores?.forEach((d: ILookmlModelExplore) => {
const modifiedDetail: DiagrammedModel = {
exploreName: d.name,
modelName: d.model_name,
diagramDict: generateExploreDiagram(d, hiddenToggle, displayFieldType),
if (exploreName && d.name === exploreName) {
const modifiedDetail: DiagrammedModel = {
exploreName: d.name,
modelName: d.model_name,
diagramDict: generateExploreDiagram(d, hiddenToggle, displayFieldType),
}
const minimapDimensions = generateMinimapDiagram(
modifiedDetail.diagramDict
)
modifiedDetail.minimapX = minimapDimensions.x
modifiedDetail.minimapY = minimapDimensions.y
modifiedDetail.minimapScale = minimapDimensions.scale
modifiedDetail.minimapDefault = minimapDimensions.default
modifiedDetails.push(modifiedDetail)
}
const minimapDimensions = generateMinimapDiagram(modifiedDetail.diagramDict)
modifiedDetail.minimapX = minimapDimensions.x
modifiedDetail.minimapY = minimapDimensions.y
modifiedDetail.minimapScale = minimapDimensions.scale
modifiedDetail.minimapDefault = minimapDimensions.default
modifiedDetails.push(modifiedDetail)
})
return modifiedDetails
}
16 changes: 14 additions & 2 deletions src/utils/fetchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type {
} from '@looker/sdk/lib/4.0/models'
import type { DiagrammedModel } from './LookmlDiagrammer'
import { generateModelDiagrams } from './LookmlDiagrammer'
import { usePathNames } from './routes'

export interface DetailedModel {
model: ILookmlModel
Expand Down Expand Up @@ -137,11 +138,22 @@ export function useModelDiagrams(
// Removing git branches as it causes a double render
const tempModelDetail = { ...modelDetail } as Partial<DetailedModel>
delete tempModelDetail.gitBranches

const { exploreName } = usePathNames()
const queryCacheKey =
JSON.stringify(tempModelDetail) + hiddenToggle + displayFieldType
JSON.stringify(tempModelDetail) +
hiddenToggle +
displayFieldType +
exploreName
const { data } = useQuery(
queryCacheKey,
() => generateModelDiagrams(modelDetail, hiddenToggle, displayFieldType),
() =>
generateModelDiagrams(
modelDetail,
hiddenToggle,
displayFieldType,
exploreName
),
{
...defaultQueryOptions,
initialData: undefined,
Expand Down