useFetchIssueCounts.tsx 966 B

123456789101112131415161718192021222324252627282930313233343536
  1. import type {ApiQueryKey, UseApiQueryOptions} from 'sentry/utils/queryClient';
  2. import {useApiQuery} from 'sentry/utils/queryClient';
  3. import type {QueryCount, QueryCounts} from 'sentry/views/issueList/utils';
  4. interface FetchIssueCountsParameters {
  5. environment: string[];
  6. orgSlug: string;
  7. project: number[];
  8. query: string[];
  9. end?: string | null;
  10. groupStatsPeriod?: string | null;
  11. sort?: string;
  12. start?: string | null;
  13. statsPeriod?: string | null;
  14. useGroupSnubaDataset?: boolean;
  15. }
  16. export const makeFetchIssueCounts = ({
  17. orgSlug,
  18. ...requestParams
  19. }: FetchIssueCountsParameters): ApiQueryKey => [
  20. `/organizations/${orgSlug}/issues-count/`,
  21. {
  22. query: requestParams,
  23. },
  24. ];
  25. export const useFetchIssueCounts = (
  26. params: FetchIssueCountsParameters,
  27. options: Partial<UseApiQueryOptions<Record<string, QueryCount>>> = {}
  28. ) => {
  29. return useApiQuery<QueryCounts>(makeFetchIssueCounts(params), {
  30. staleTime: 0,
  31. ...options,
  32. });
  33. };