code review
Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
This commit is contained in:
parent
9b3333fa76
commit
01e5d50464
|
@ -7,6 +7,7 @@ import { ENDPOINTS } from '../stores/useWalletStore'
|
||||||
import { getGovernanceAccounts, pubkeyFilter } from './api'
|
import { getGovernanceAccounts, pubkeyFilter } from './api'
|
||||||
|
|
||||||
const fiveMinutesSeconds = 5 * 60
|
const fiveMinutesSeconds = 5 * 60
|
||||||
|
const toleranceSeconds = 30
|
||||||
|
|
||||||
// run every 5 mins, checks if a mngo governance proposal just opened in the last 5 mins
|
// run every 5 mins, checks if a mngo governance proposal just opened in the last 5 mins
|
||||||
// and notifies on WEBHOOK_URL
|
// and notifies on WEBHOOK_URL
|
||||||
|
@ -65,8 +66,9 @@ async function runNotifier() {
|
||||||
)
|
)
|
||||||
|
|
||||||
console.log(`- scanning all proposals`)
|
console.log(`- scanning all proposals`)
|
||||||
let countJustOpened = 0
|
let countJustOpenedForVoting = 0
|
||||||
let countSkipped = 0
|
let countVotingNotStartedYet = 0
|
||||||
|
let countClosed = 0
|
||||||
for (const k in realmProposals) {
|
for (const k in realmProposals) {
|
||||||
const proposal = realmProposals[k]
|
const proposal = realmProposals[k]
|
||||||
|
|
||||||
|
@ -74,24 +76,24 @@ async function runNotifier() {
|
||||||
// voting is closed
|
// voting is closed
|
||||||
proposal.info.votingCompletedAt
|
proposal.info.votingCompletedAt
|
||||||
) {
|
) {
|
||||||
countSkipped++
|
countClosed++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// not yet signed i.e. only in draft
|
// voting has not started yet
|
||||||
!proposal.info.signingOffAt
|
!proposal.info.votingAt
|
||||||
) {
|
) {
|
||||||
countSkipped++
|
countVotingNotStartedYet++
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
// proposal opened in last 5 mins
|
// proposal opened in last 5 mins
|
||||||
nowInSeconds - proposal.info.signingOffAt.toNumber() <=
|
nowInSeconds - proposal.info.votingAt.toNumber() <=
|
||||||
fiveMinutesSeconds
|
fiveMinutesSeconds + toleranceSeconds
|
||||||
) {
|
) {
|
||||||
countJustOpened++
|
countJustOpenedForVoting++
|
||||||
const msg = `--- ${proposal.info.name} proposal just opened for voting`
|
const msg = `--- ${proposal.info.name} proposal just opened for voting`
|
||||||
console.log(msg)
|
console.log(msg)
|
||||||
if (process.env.WEBHOOK_URL) {
|
if (process.env.WEBHOOK_URL) {
|
||||||
|
@ -100,7 +102,7 @@ async function runNotifier() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
`-- countJustOpened: ${countJustOpened}, countSkipped: ${countSkipped}`
|
`-- countJustOpenedForVoting: ${countJustOpenedForVoting}, countVotingNotStartedYet: ${countVotingNotStartedYet}, countClosed: ${countClosed}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue