widgetToQuery.tsx 778 B

1234567891011121314151617181920212223
  1. import {isMetricsEquationWidget, type MetricsWidget} from 'sentry/utils/metrics/types';
  2. import type {MetricsQueryApiQueryParams} from 'sentry/utils/metrics/useMetricsQuery';
  3. import {getEquationSymbol} from 'sentry/views/metrics/equationSymbol';
  4. import {getQuerySymbol} from 'sentry/views/metrics/querySymbol';
  5. export function widgetToQuery(
  6. widget: MetricsWidget,
  7. isQueryOnly = false
  8. ): MetricsQueryApiQueryParams {
  9. return isMetricsEquationWidget(widget)
  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. }