Skip to content

Commit

Permalink
Use bulk create for gpus&cpus
Browse files Browse the repository at this point in the history
  • Loading branch information
Redm4x committed Feb 27, 2024
1 parent 5b2d402 commit b0982b6
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions indexer/src/providers/providerStatusProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,31 +164,27 @@ async function saveProviderStatus(
{ transaction: t }
);

for (const cpuInfo of node.cpus) {
await ProviderSnapshotNodeCPU.create(
{
snapshotNodeId: providerSnapshotNode.id,
vendor: cpuInfo.vendor,
model: cpuInfo.model,
vcores: cpuInfo.vcores
},
{ transaction: t }
);
}
await ProviderSnapshotNodeCPU.bulkCreate(
node.cpus.map((cpuInfo) => ({
snapshotNodeId: providerSnapshotNode.id,
vendor: cpuInfo.vendor,
model: cpuInfo.model,
vcores: cpuInfo.vcores
})),
{ transaction: t }
);

for (const gpuInfo of node.gpus) {
await ProviderSnapshotNodeGPU.create(
{
snapshotNodeId: providerSnapshotNode.id,
vendor: gpuInfo.vendor,
name: gpuInfo.name,
modelId: gpuInfo.modelId,
interface: gpuInfo.interface,
memorySize: gpuInfo.memorySize // TODO: Change type to bytes?
},
{ transaction: t }
);
}
await ProviderSnapshotNodeGPU.bulkCreate(
node.gpus.map((gpuInfo) => ({
snapshotNodeId: providerSnapshotNode.id,
vendor: gpuInfo.vendor,
name: gpuInfo.name,
modelId: gpuInfo.modelId,
interface: gpuInfo.interface,
memorySize: gpuInfo.memorySize // TODO: Change type to bytes?
})),
{ transaction: t }
);
}
}
});
Expand Down

0 comments on commit b0982b6

Please sign in to comment.