From a40fa8389388a72e0775e98c2299f870e93adad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jamr=C3=B3z?= Date: Fri, 4 Feb 2022 17:05:46 +0100 Subject: [PATCH] Query History: Remove unused properties (#44904) * Remove unused properties * Fix unit tests * Fix unit tests --- .../core/history/RichHistoryLocalStorage.test.ts | 4 ---- public/app/core/utils/richHistory.test.ts | 14 -------------- public/app/core/utils/richHistory.ts | 4 ---- .../explore/RichHistory/RichHistoryCard.test.tsx | 4 ---- public/app/features/explore/Wrapper.test.tsx | 1 - public/app/features/explore/state/query.ts | 2 -- public/app/types/explore.ts | 3 --- 7 files changed, 32 deletions(-) diff --git a/public/app/core/history/RichHistoryLocalStorage.test.ts b/public/app/core/history/RichHistoryLocalStorage.test.ts index 00f20f48e09..b4fb8823a2a 100644 --- a/public/app/core/history/RichHistoryLocalStorage.test.ts +++ b/public/app/core/history/RichHistoryLocalStorage.test.ts @@ -11,9 +11,7 @@ const mockItem: RichHistoryQuery = { ts: 2, starred: true, datasourceName: 'dev-test', - datasourceId: 'test-id', comment: 'test', - sessionName: 'session-name', queries: [{ refId: 'ref', query: 'query-test' } as DataQuery], }; @@ -21,9 +19,7 @@ const mockItem2: RichHistoryQuery = { ts: 3, starred: true, datasourceName: 'dev-test-2', - datasourceId: 'test-id-2', comment: 'test-2', - sessionName: 'session-name-2', queries: [{ refId: 'ref-2', query: 'query-2' } as DataQuery], }; diff --git a/public/app/core/utils/richHistory.test.ts b/public/app/core/utils/richHistory.test.ts index 62036265d2d..eb12d22f46c 100644 --- a/public/app/core/utils/richHistory.test.ts +++ b/public/app/core/utils/richHistory.test.ts @@ -26,13 +26,11 @@ const mock: any = { storedHistory: [ { comment: '', - datasourceId: 'datasource historyId', datasourceName: 'datasource history name', queries: [ { expr: 'query1', maxLines: null, refId: '1' }, { expr: 'query2', refId: '2' }, ], - sessionName: '', starred: true, ts: 1, }, @@ -75,10 +73,8 @@ describe('richHistory', () => { const expectedResult = [ { comment: mock.testComment, - datasourceId: mock.testDatasourceId, datasourceName: mock.testDatasourceName, queries: mock.testQueries, - sessionName: mock.testSessionName, starred: mock.testStarred, ts: 2, }, @@ -89,12 +85,10 @@ describe('richHistory', () => { Date.now = jest.fn(() => 2); const { richHistory: newHistory } = await addToRichHistory( mock.storedHistory, - mock.testDatasourceId, mock.testDatasourceName, mock.testQueries, mock.testStarred, mock.testComment, - mock.testSessionName, true, true ); @@ -106,22 +100,18 @@ describe('richHistory', () => { const { richHistory } = await addToRichHistory( mock.storedHistory, - mock.testDatasourceId, mock.testDatasourceName, mock.testQueries, mock.testStarred, mock.testComment, - mock.testSessionName, true, true ); expect(richHistory).toMatchObject(expectedResult); expect(richHistoryStorageMock.addToRichHistory).toBeCalledWith({ datasourceName: mock.testDatasourceName, - datasourceId: mock.testDatasourceId, starred: mock.testStarred, comment: mock.testComment, - sessionName: mock.testSessionName, queries: mock.testQueries, ts: 2, }); @@ -136,12 +126,10 @@ describe('richHistory', () => { const { richHistory: newHistory } = await addToRichHistory( mock.storedHistory, - mock.storedHistory[0].datasourceId, mock.storedHistory[0].datasourceName, [{ expr: 'query1', maxLines: null, refId: 'A' } as DataQuery, { expr: 'query2', refId: 'B' } as DataQuery], mock.testStarred, mock.testComment, - mock.testSessionName, true, true ); @@ -158,12 +146,10 @@ describe('richHistory', () => { const { richHistory, limitExceeded } = await addToRichHistory( mock.storedHistory, - mock.testDatasourceId, mock.testDatasourceName, mock.testQueries, mock.testStarred, mock.testComment, - mock.testSessionName, true, true ); diff --git a/public/app/core/utils/richHistory.ts b/public/app/core/utils/richHistory.ts index c3cb698a2b2..c2757d28c94 100644 --- a/public/app/core/utils/richHistory.ts +++ b/public/app/core/utils/richHistory.ts @@ -34,12 +34,10 @@ export { SortOrder }; export async function addToRichHistory( richHistory: RichHistoryQuery[], - datasourceId: string, datasourceName: string | null, queries: DataQuery[], starred: boolean, comment: string | null, - sessionName: string, showQuotaExceededError: boolean, showLimitExceededWarning: boolean ): Promise<{ richHistory: RichHistoryQuery[]; richHistoryStorageFull?: boolean; limitExceeded?: boolean }> { @@ -51,11 +49,9 @@ export async function addToRichHistory( const newRichHistory: RichHistoryQuery = { queries: newQueriesToSave, ts, - datasourceId, datasourceName: datasourceName ?? '', starred, comment: comment ?? '', - sessionName, }; let richHistoryStorageFull = false; diff --git a/public/app/features/explore/RichHistory/RichHistoryCard.test.tsx b/public/app/features/explore/RichHistory/RichHistoryCard.test.tsx index 212408f3e36..80210bca91c 100644 --- a/public/app/features/explore/RichHistory/RichHistoryCard.test.tsx +++ b/public/app/features/explore/RichHistory/RichHistoryCard.test.tsx @@ -9,7 +9,6 @@ const setup = (propOverrides?: Partial) => { query: { ts: 1, datasourceName: 'Test datasource', - datasourceId: 'datasource 1', starred: false, comment: '', queries: [ @@ -17,7 +16,6 @@ const setup = (propOverrides?: Partial) => { { expr: 'query2', refId: 'B' } as DataQuery, { expr: 'query3', refId: 'C' } as DataQuery, ], - sessionName: '', }, dsImg: '/app/img', isRemoved: false, @@ -37,7 +35,6 @@ const setup = (propOverrides?: Partial) => { const starredQueryWithComment = { ts: 1, datasourceName: 'Test datasource', - datasourceId: 'datasource 1', starred: true, comment: 'test comment', queries: [ @@ -45,7 +42,6 @@ const starredQueryWithComment = { { query: 'query2', refId: 'B' }, { query: 'query3', refId: 'C' }, ], - sessionName: '', }; describe('RichHistoryCard', () => { diff --git a/public/app/features/explore/Wrapper.test.tsx b/public/app/features/explore/Wrapper.test.tsx index 1c964abef98..7d10a6e7a86 100644 --- a/public/app/features/explore/Wrapper.test.tsx +++ b/public/app/features/explore/Wrapper.test.tsx @@ -103,7 +103,6 @@ describe('Wrapper', () => { }); expect(store.getState().explore.richHistory[0]).toMatchObject({ - datasourceId: '1', datasourceName: 'loki', queries: [{ expr: '{ label="value"}', refId: 'A' }], }); diff --git a/public/app/features/explore/state/query.ts b/public/app/features/explore/state/query.ts index ee503c3375a..372a9304319 100644 --- a/public/app/features/explore/state/query.ts +++ b/public/app/features/explore/state/query.ts @@ -326,12 +326,10 @@ async function handleHistory( limitExceeded, } = await addToRichHistory( state.richHistory || [], - datasourceId, datasource.name, queries, false, '', - '', !state.richHistoryStorageFull, !state.richHistoryLimitExceededWarningShown ); diff --git a/public/app/types/explore.ts b/public/app/types/explore.ts index c75b6032efb..396809ae76b 100644 --- a/public/app/types/explore.ts +++ b/public/app/types/explore.ts @@ -204,12 +204,9 @@ export interface QueryTransaction { export type RichHistoryQuery = { ts: number; datasourceName: string; - datasourceId: string; starred: boolean; comment: string; queries: DataQuery[]; - sessionName: string; - timeRange?: string; }; export interface ExplorePanelData extends PanelData {