grafana/public/test/mocks/query.ts
Piotr Jamróz a7238ba933
Explore: Support mixed data sources for supplementary query (#63036)
* Consolidate logs volume logic (full range and limited)

* Fix showing limited histogram message

* Test passing meta data to logs volume provider

* Improve readability

* Clean up types

* Add basic support for multiple log volumes

* Move the comment back to the right place

* Improve readability

* Clean up the logic to support Logs Samples

* Update docs

* Sort log volumes

* Provide title to logs volume panel

* Move logs volume cache to the provider factory

* Add helper functions

* Reuse only if queries are the same

* Fix alphabetical sorting

* Move caching out of the provider

* Support errors and loading state

* Remove unused code

* Consolidate supplementary query utils

* Add tests for supplementaryQueries

* Update tests

* Simplify logs volume extra info

* Update tests

* Remove comment

* Update tests

* Fix hiding the histogram for hidden queries

* Simplify loading message

* Update tests

* Wait for full fallback histogram to load before showing it

* Fix a typo

* Add feedback comments

* Move feedback comments to github

* Do not filter out hidden queries as they may be used as references in other queries

* Group log volume by refId

* Support showing fallback histograms per query to avoid duplicates

* Improve type-checking

* Fix supplementaryQueries.test.ts

* Fix logsModel.test.ts

* Fix loading fallback results

* Fix unit tests

* WIP

* Update deprecated styles

* Simplify test

* Simplify rendering zoom info

* Update deprecated styles

* Simplify getLogsVolumeDataSourceInfo

* Simplify isLogsVolumeLimited()

* Simplify rendering zoom info
2023-03-07 15:00:11 +01:00

31 lines
795 B
TypeScript

import { CoreApp, DataQueryRequest, getDefaultTimeRange } from '@grafana/data';
import { DataQuery, DataSourceRef } from '@grafana/schema';
export class MockQuery implements DataQuery {
refId: string;
testQuery: string;
datasource?: DataSourceRef;
constructor(refId = 'A', testQuery = '', datasourceRef?: DataSourceRef) {
this.refId = refId;
this.testQuery = testQuery;
this.datasource = datasourceRef;
}
}
export class MockDataQueryRequest implements DataQueryRequest<MockQuery> {
app = CoreApp.Unknown;
interval = '';
intervalMs = 0;
range = getDefaultTimeRange();
requestId = '1';
scopedVars = {};
startTime = 0;
targets: MockQuery[];
timezone = 'utc';
constructor({ targets }: { targets: MockQuery[] }) {
this.targets = targets || [];
}
}