Skip to content

Commit

Permalink
NEOS-1605: Fixes job run logs not loading, fixes inability to specify…
Browse files Browse the repository at this point in the history
… log level (#3172)
  • Loading branch information
nickzelei authored Jan 21, 2025
1 parent 0807f85 commit 8f572a8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { withNeosyncContext } from '@/api-only/neosync-context';
import { RequestContext } from '@/shared';
import { create } from '@bufbuild/protobuf';
import { create, JsonValue, toJson } from '@bufbuild/protobuf';
import {
GetJobRunLogsStreamRequestSchema,
GetJobRunLogsStreamResponse,
GetJobRunLogsStreamResponseSchema,
LogLevel,
LogWindow,
} from '@neosync/sdk';
Expand All @@ -26,9 +26,9 @@ export async function GET(
logLevels: [loglevel ? parseInt(loglevel, 10) : LogLevel.UNSPECIFIED],
})
);
const logs: GetJobRunLogsStreamResponse[] = [];
const logs: JsonValue[] = [];
for await (const logRes of response) {
logs.push(logRes);
logs.push(toJson(GetJobRunLogsStreamResponseSchema, logRes));
}
return logs;
})(req);
Expand Down
10 changes: 8 additions & 2 deletions frontend/apps/web/libs/hooks/useGetJobRunLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export function useGetJobRunLogs(
'?',
query.toString(),
],
queryFn: (ctx) => fetcher(ctx.queryKey.join('/')),
queryFn: (ctx) => {
const queryKey = ctx.queryKey;
const questionMarkIndex = queryKey.indexOf('?');
const baseUrl = queryKey.slice(0, questionMarkIndex).join('/');
const queryParams = queryKey.slice(questionMarkIndex + 1).join('');
return fetcher(`${baseUrl}?${queryParams}`);
},
refetchInterval(query) {
return query.state.data && refreshIntervalFn
? refreshIntervalFn(query.state.data)
Expand All @@ -46,7 +52,7 @@ export function useGetJobRunLogs(
: fromJson(GetJobRunLogsStreamResponseSchema, d)
);
},
enabled: !!runId && !!accountId && !!loglevel,
enabled: !!runId && !!accountId,
});
}

Expand Down

0 comments on commit 8f572a8

Please sign in to comment.