Skip to content

Commit

Permalink
fix: showing what core the chain is renewed on (#11256)
Browse files Browse the repository at this point in the history
* fix: showing what core the chain is renewed on

* removed the code that is part of another pr

* better wording
  • Loading branch information
piggydoughnut authored Feb 5, 2025
1 parent bf8346e commit e5b2b48
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/react-hooks/src/useCoretimeInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,21 @@ function useCoretimeInformationImpl (api: ApiPromise, ready: boolean): CoretimeI
const workloads = workloadData?.filter((one) => one.info.task === taskId);

const workTaskInfo = workloads.map((workload) => {
const workplan = workplans?.filter((workplan) => workplan.core === workload?.core && workplan.info.task.toString() === taskId);
// parachain can be renewed on a different core
const workplan = workplans?.filter((workplan) => workplan.info.task.toString() === taskId);
const type = getOccupancyType(lease, reservation, workload?.info.isPool ?? false);
const chainRenewedCore = type === CoreTimeTypes['Bulk Coretime'] && workplan?.find((a) => a.core === workload?.core);
const renewal = potentialRenewalsCurrentRegion?.find((renewal) => renewal.task.toString() === taskId);
const renewalStatus = chainRenewedCore ? ChainRenewalStatus.Renewed : renewal ? ChainRenewalStatus.Eligible : ChainRenewalStatus.None;
const potentialRenewal = potentialRenewalsCurrentRegion?.find((renewal) => renewal.task.toString() === taskId);

let renewalStatus = potentialRenewal ? ChainRenewalStatus.Eligible : ChainRenewalStatus.None;
const chainRenewedCore = type === CoreTimeTypes['Bulk Coretime'] && !!workplan?.length;

if (chainRenewedCore) {
renewalStatus = `Next cycle on core ${workplan[0].core}`;
}

return {
chainRenewedCore,
renewal,
renewal: potentialRenewal,
renewalStatus,
type,
workload,
Expand Down

0 comments on commit e5b2b48

Please sign in to comment.