-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(insights): Replace usage of
<ReleaseSeries>
in `<InsightsTimeSe…
…riesWidget>` (#86129) ...with a hook (`useReleaseStats`) This will be needed for the new release bubbles feature as we will show releases on the mini widgets instead of only on fullscreen. Using `<ReleaseSeries>` renderer will cause duplicate requests to the API. ref #85779
- Loading branch information
Showing
13 changed files
with
174 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
static/app/views/dashboards/widgets/timeSeriesWidget/useReleaseStats.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import {normalizeDateTimeParams} from 'sentry/components/organizations/pageFilters/parse'; | ||
import type {PageFilters} from 'sentry/types/core'; | ||
import {useInfiniteApiQuery} from 'sentry/utils/queryClient'; | ||
import useOrganization from 'sentry/utils/useOrganization'; | ||
|
||
interface ReleaseMetaBasic { | ||
date: string; | ||
version: string; | ||
} | ||
|
||
/** | ||
* Fetches *ALL* releases (e.g. all pages worth) | ||
*/ | ||
export function useReleaseStats({datetime, environments, projects}: PageFilters) { | ||
const organization = useOrganization(); | ||
|
||
const { | ||
isLoading, | ||
isFetching, | ||
fetchNextPage, | ||
hasNextPage, | ||
isPending, | ||
isError, | ||
error, | ||
data, | ||
} = useInfiniteApiQuery<ReleaseMetaBasic[]>({ | ||
queryKey: [ | ||
`/organizations/${organization.slug}/releases/stats/`, | ||
{ | ||
query: { | ||
environment: environments, | ||
project: projects, | ||
...normalizeDateTimeParams(datetime), | ||
}, | ||
}, | ||
], | ||
staleTime: Infinity, | ||
}); | ||
|
||
if (!isFetching && hasNextPage) { | ||
fetchNextPage(); | ||
} | ||
|
||
const releases = | ||
data?.pages.flatMap(([pageData]) => | ||
pageData.map(({date, version}) => ({timestamp: date, version})) | ||
) ?? []; | ||
|
||
return { | ||
isLoading, | ||
isPending, | ||
isError, | ||
error, | ||
releases, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters