diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84e0680..383e37b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -46,4 +46,4 @@ jobs: -X POST \ -H "Authorization: Bearer ${{ secrets.RAILWAY_TOKEN }}" \ -H "Content-Type: application/json" \ - --data "{\"query\":\"mutation { deploymentRedeploy(id: \\\"${{ secrets.RAILWAY_DEPLOYMENT_ID }}\\\") { status } }\"}" \ + --data '{"query": "mutation serviceInstanceDeploy($serviceId: String!, $environmentId: String!) {\n serviceInstanceDeploy(serviceId: $serviceId, environmentId: $environmentId)\n}\n", "variables": { "environmentId": "0942e3fe-8ec3-49b4-b8fb-26eb10b6e08f", "serviceId": "783719dc-3c30-437d-a3a9-b1aeb1d5c487" } }' diff --git a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts index e1aad55..3d1ba62 100644 --- a/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts +++ b/packages/indexer/src/indexers/autocrat/autocrat-proposal-indexer.ts @@ -222,25 +222,28 @@ export const AutocratProposalIndexer: IntervalFetchIndexer = { if (!dbDao) continue; - const endSlot: BN = onChainProposal.account.slotEnqueued.add( - new BN(dbDao.slotsPerProposal?.valueOf()) - ); + // Setup for calculating time left + const initialSlot = new BN(onChainProposal.account.slotEnqueued.toString()); - const slotDifference = onChainProposal.account.slotEnqueued - .add(new BN(dbDao.slotsPerProposal?.valueOf())) - .sub(new BN(currentSlot)); + const slotsPerProposal = new BN(dbDao.slotsPerProposal?.toString()); - const lowHoursEstimate = Math.floor( - (slotDifference.toNumber() * 400) / 1000 / 60 / 60 - ); + //const endSlot: BN = initialSlot.add(slotsPerProposal); + + const currentSlotBN = new BN(currentSlot.toString()); + + const slotDifference = initialSlot + .add(slotsPerProposal) + .sub(currentSlotBN); - // Our check to ensure we're actually updating the time correctly. - if (currentSlot <= endSlot.toNumber() && lowHoursEstimate <= 0) { - console.error("Issue with slot update contact administrator"); - } + // Setup time to add to the date.. + const timeLeftSecondsEstimate = (slotDifference.toNumber() * 400) / 1000 // MS to seconds + // const timeLeftMinutesEstimate = timeLeftSecondsEstimate / 60 // MS to seconds to minutes + // const timeLeftHoursEstimate = timeLeftMinutesEstimate / 60 const endedAt = new Date(currentTime.toUTCString()); - endedAt.setHours(endedAt.getHours() + lowHoursEstimate); + // endedAt.setHours(endedAt.getHours() + timeLeftHoursEstimate); + // endedAt.setMinutes(endedAt.getMinutes() + timeLeftMinutesEstimate); + endedAt.setSeconds(endedAt.getSeconds() + timeLeftSecondsEstimate); // setSeconds accepts float and will increase to hours etc. await usingDb((db) => db