Skip to content

Commit

Permalink
Do not fail if tickets could not be fetched (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
petersutter authored Jun 4, 2024
1 parent 89f8092 commit cc08989
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions frontend/src/store/shoot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,31 +321,48 @@ export const useShootStore = defineStore('shoot', () => {

const fetchShoot = async options => {
const [
{ data: shoot },
{ data: { issues = [], comments = [] } },
] = await Promise.all([
{ value: shootResult, reason: shootError },
{ value: issuesAndCommentsResult, reason: issuesAndCommentsError },
] = await Promise.allSettled([
api.getShoot(options),
api.getIssuesAndComments(options),
])
if (shootError) {
throw shootError
}
logger.debug('Fetched shoot for %s in namespace %s', options.name, options.namespace)
if (issuesAndCommentsError) {
logger.warn('Tickets could not be fetched:', issuesAndCommentsError.message)
}
const {
issues = [],
comments = [],
} = issuesAndCommentsResult?.data ?? {}
// fetch shootInfo in the background (do not await the promise)
shootStore.fetchInfo(shoot.metadata)
logger.debug('Fetched shoot and tickets for %s in namespace %s', options.name, options.namespace)
return { shoots: [shoot], issues, comments }
shootStore.fetchInfo(shootResult.data.metadata)
return { shoots: [shootResult.data], issues, comments }
}

const fetchShoots = async options => {
const { namespace } = options
const [
{ data: { items } },
{ data: { issues = [] } },
] = await Promise.all([
{ value: shootsResult, reason: shootsError },
{ value: issuesResult, reason: issuesError },
] = await Promise.allSettled([
api.getShoots(options),
api.getIssues({ namespace }),
])
logger.debug('Fetched shoots and tickets in namespace %s', options.namespace)
return { shoots: items, issues, comments: [] }
if (shootsError) {
throw shootsError
}
logger.debug('Fetched shoots in namespace %s', options.namespace)
if (issuesError) {
logger.warn('Error fetching issues:', issuesError.message)
}
const { items: shoots } = shootsResult?.data ?? {}
const { issues = [] } = issuesResult?.data ?? {}
return { shoots, issues, comments: [] }
}

const getThrottleDelay = (options, n) => {
if (options.name) {
return 0
Expand Down

0 comments on commit cc08989

Please sign in to comment.