widgetToQuery.tsx 795 B

1234567891011121314151617181920212223
  1. import {MetricQueryType, type MetricWidgetQueryParams} from 'sentry/utils/metrics/types';
  2. import type {MetricsQueryApiQueryParams} from 'sentry/utils/metrics/useMetricsQuery';
  3. import {getEquationSymbol} from 'sentry/views/ddm/equationSymbol copy';
  4. import {getQuerySymbol} from 'sentry/views/ddm/querySymbol';
  5. export function widgetToQuery(
  6. widget: MetricWidgetQueryParams,
  7. isQueryOnly = false
  8. ): MetricsQueryApiQueryParams {
  9. return widget.type === MetricQueryType.FORMULA
  10. ? {
  11. name: getEquationSymbol(widget.id),
  12. formula: widget.formula,
  13. }
  14. : {
  15. name: getQuerySymbol(widget.id),
  16. mri: widget.mri,
  17. op: widget.op,
  18. groupBy: widget.groupBy,
  19. query: widget.query,
  20. isQueryOnly: isQueryOnly || widget.isHidden,
  21. };
  22. }