Skip to content
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

feat: Handle empty repository autodiscovery #45

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions backend/src/api/pod-progress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface PodProgressRoute {
Reply: ProgressItem[]
}

export const podProgressRoute = ({ logsController }: Controllers, config: BackendConfig): FastifyPluginAsync => async (app) => {
export const podProgressRoute = ({ podController, logsController }: Controllers, config: BackendConfig): FastifyPluginAsync => async (app) => {
app.addHook('preValidation', authenticateSession())

app.get<PodProgressRoute & {
Expand All @@ -27,7 +27,12 @@ export const podProgressRoute = ({ logsController }: Controllers, config: Backen
}
const progress = extractProgress(logs, { repositoryBaseUrl: config.gitlab.host })
if (progress == null) {
// In case the log cannot be parsed, progress is unavailable, so return a 404.
// If the pod is done, but there are no progress items, this indicates no repositories were processed.
const pod = await podController.findPod({ namespace: request.params.namespace, name: request.params.name })
if (pod?.status?.phase === 'Succeeded') {
return []
}
// The pod is either not available or still running, so progress is undefined.
return await notFound((reply))
}
return progress
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/pages/Job.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,12 @@ const Pod: FunctionComponent<{

// A value between 0 and 1 representing the progress of repositories
const progressValue = useMemo(() => {
if (progress == null || progress.length === 0) {
if (progress == null) {
return 0
}
if (progress.length === 0) {
return 1
}
let value = 0
for (const item of progress ?? []) {
switch (item.state) {
Expand Down Expand Up @@ -208,6 +211,9 @@ const Pod: FunctionComponent<{
/>
</div>
<div className='mt-4'>
{progress.length === 0 && (
<p className='py-1'>No repositories were processed.</p>
)}
{progress.map((item) => (
<ProgressItem key={item.repository} item={item} />
))}
Expand Down