Skip to content

Commit 3853af9

Browse files
committed
Refactor dataset as suggested by co-pilot
1 parent 54de40c commit 3853af9

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

src/controllers/dataset.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,20 @@ export const updateSources = async (req: Request, res: Response, next: NextFunct
538538
}
539539
}
540540

541-
const build = await BuildLog.startBuild(revision, CubeBuildType.FullCube, userId);
541+
542542

543543
const updatedDataset = await DatasetRepository.getById(dataset.id);
544-
res.json({
545-
dataset: DatasetDTO.fromDataset(updatedDataset),
546-
build_id: build.id
547-
});
544+
const build = await BuildLog.startBuild(revision, CubeBuildType.FullCube, userId);
545+
546+
try {
547+
res.status(202);
548+
res.json({
549+
dataset: DatasetDTO.fromDataset(updatedDataset),
550+
build_id: build.id
551+
});
552+
} catch (_) {
553+
await build.remove();
554+
}
548555

549556
void createAllCubeFiles(updatedDataset.id, revision.id, userId, CubeBuildType.FullCube, build).catch((err) => {
550557
logger.error(err, `Failed to create cube files for build ${build.id}`);

0 commit comments

Comments
 (0)