Skip to content

Commit

Permalink
Fix bug when the last job is still running
Browse files Browse the repository at this point in the history
  • Loading branch information
b-per committed Oct 25, 2022
1 parent 0aba908 commit 590f1b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,16 @@ export function Models(props: { env: dbtEnv, projectID: number }) {
)}`;
const results_json: dbtJobsAnswer = (await fetchCloudApiData(url_api)) as dbtJobsAnswer;

// We loop through the list and crate a dict with id as the key and name as the value
// We loop through the list and create a dict with id as the key and name as the value
setJobIdNameMapping(Object.assign({}, ...results_json.data.map((x) => ({ [x.id]: x.name }))));


const urlAPIRuns =
`https://cloud.getdbt.com/api/v4/accounts/${accountId}/runs?` + encodeURI(`project=${projectId}`);
const resultsAPIRuns = (await fetchCloudApiData(urlAPIRuns)) as dbtRunsAnswer;
const runId = resultsAPIRuns.data[0].id;

// We get the last job that has finished (which means it will have artefacts)
const runId = resultsAPIRuns.data.filter((x) => x.finished_at !== null)[0].id;

const urlAPIManifest = `https://cloud.getdbt.com/api/v2/accounts/${accountId}/runs/${runId}/artifacts/manifest.json`;

Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export interface dbtRunsAnswer {
data: [
{
id: number;
finished_at: number;
}
];
}
Expand Down

0 comments on commit 590f1b4

Please sign in to comment.