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

sourcerer problem reproduced #181540

Closed
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
38 changes: 23 additions & 15 deletions src/plugins/data_views/common/data_views/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -824,12 +824,20 @@ export class DataViewsService {
displayErrors?: boolean;
}) => {
const { title, type, typeMeta, runtimeFieldMap } = spec;

console.log('============= initFromSavedObjectLoadFields', savedObjectId, title);

const pattern =
savedObjectId === 'alerts' && true ? '.alerts-security.alerts-default' : (title as string);

console.log('============= initFromSavedObjectLoadFields', pattern);

const { fields, indices, etag } = await this.refreshFieldSpecMap(
spec.fields || {},
savedObjectId,
spec.title as string,
{
pattern: title as string,
pattern,
metaFields: await this.getMetaFields(),
type,
rollupIndex: typeMeta?.params?.rollup_index,
Expand Down Expand Up @@ -997,20 +1005,20 @@ export class DataViewsService {
displayErrors: boolean = true,
refreshFields = false
): Promise<DataView> => {
const dataViewFromCache = this.dataViewCache.get(id)?.then(async (dataView) => {
if (dataView && refreshFields) {
await this.refreshFields(dataView, displayErrors);
}
return dataView;
});

let indexPatternPromise: Promise<DataView>;
if (dataViewFromCache) {
indexPatternPromise = dataViewFromCache;
} else {
indexPatternPromise = this.getSavedObjectAndInit(id, displayErrors);
this.dataViewCache.set(id, indexPatternPromise);
}
// const dataViewFromCache = this.dataViewCache.get(id)?.then(async (dataView) => {
// if (dataView && refreshFields) {
// await this.refreshFields(dataView, displayErrors);
// }
// return dataView;
// });

// let indexPatternPromise: Promise<DataView>;
// if (dataViewFromCache) {
// indexPatternPromise = dataViewFromCache;
// } else {
const indexPatternPromise = this.getSavedObjectAndInit(id, displayErrors);
this.dataViewCache.set(id, indexPatternPromise);
// }

// don't cache failed requests
indexPatternPromise.catch(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,11 @@ export const useSourcererDataView = (
const selectedDataView = useMemo(() => {
return kibanaDataViews.find((dataView) => dataView.id === selectedDataViewId);
}, [kibanaDataViews, selectedDataViewId]);

// FIXME:
console.log('selectedDataView', selectedDataViewId, selectedDataView);
console.log('defaultDataView', defaultDataView);

const loading = useSelector((state: State) => {
return sourcererSelectors.sourcererScopeIsLoading(state, scopeId);
});
Expand Down Expand Up @@ -485,6 +490,7 @@ export const useSourcererDataView = (
browserFields: browserFields(),
dataViewId: sourcererDataView.id,
indexPattern: {
// FIXME: fix this omg
fields: sourcererDataView.indexFields,
title: selectedPatterns.join(','),
getName: () => selectedPatterns.join(','),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const kibanaDataViews = createSelector(

export const defaultDataView = createSelector(
selectSourcerer,
(sourcerer) => sourcerer.defaultDataView,
(sourcerer) => sourcerer.kibanaDataViews.find(({ id }) => id === 'alerts') as any,
{
memoizeOptions: {
maxSize: SOURCERER_SCOPE_MAX_SIZE,
Expand Down