-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NCL-8675] Add latest Brew Push column to Group Build Builds list #486
base: main
Are you sure you want to change the base?
Changes from all commits
7e199ad
33a39c1
458a4ce
5ce2ab0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { AxiosRequestConfig } from 'axios'; | ||
import axios, { AxiosRequestConfig, AxiosResponse, isAxiosError } from 'axios'; | ||
|
||
import { BuildPage, BuildsGraph, GroupBuild, GroupBuildPage } from 'pnc-api-types-ts'; | ||
|
||
import { BuildWithBrewPushPage } from 'services/buildApi'; | ||
import * as buildApi from 'services/buildApi'; | ||
|
||
import { extendRequestConfig } from 'utils/requestConfigHelper'; | ||
|
||
import { pncClient } from './pncClient'; | ||
|
@@ -66,6 +69,36 @@ export const getBuilds = ({ id }: IGroupBuildApiData, requestConfig: AxiosReques | |
return pncClient.getHttpClient().get<BuildPage>(`/group-builds/${id}/builds`, requestConfig); | ||
}; | ||
|
||
/** | ||
* Gets Builds contained in the Group Build along with latest Brew Push result. | ||
* | ||
* @param requestConfig - Axios based request config | ||
*/ | ||
export const getBuildsWithBrewPush = async ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Current implementation is blocking whole lits just because of one column, even if some users / use-cases don't need that column at all. Anyway soon we will be implementing the similar functionality on other top-level pages, where blocking way would be very limiting and probably not possible due to performance issues. Possible solution could be creating separated latestBrewPush component managing its state independently? I understand there can be some other technical difficulties, if so, feel free to reach me directly and we can investigate other possible solutions together. |
||
{ id }: IGroupBuildApiData, | ||
requestConfig: AxiosRequestConfig = {} | ||
): Promise<AxiosResponse<BuildWithBrewPushPage>> => { | ||
const buildsResponse = await getBuilds({ id }, requestConfig); | ||
if (!buildsResponse.data.content?.length) return buildsResponse; | ||
|
||
const buildsWithBrewPush = await axios.all( | ||
buildsResponse.data.content.map(async (build) => { | ||
try { | ||
const { data } = await buildApi.getBrewPush({ id: build.id }); | ||
return data ? { ...build, brewPush: data } : build; | ||
} catch (error) { | ||
if (isAxiosError(error) && error.response?.status === 404) { | ||
return build; | ||
} | ||
|
||
throw error; | ||
} | ||
}) | ||
); | ||
|
||
return { ...buildsResponse, data: { ...buildsResponse.data, content: buildsWithBrewPush } }; | ||
}; | ||
|
||
/** | ||
* Gets dependency graph for a group build. | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dead code, it should be removed until it's really need