-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1106 from Giveth/feat/addFillSnapshotAgain
Added fill snapshot round number
- Loading branch information
Showing
3 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { | ||
findInCompletePowerSnapShots, | ||
updatePowerSnapShots, | ||
} from '../repositories/powerSnapshotRepository'; | ||
import { getTimestampInSeconds } from '../utils/utils'; | ||
import { getRoundNumberByDate } from '../utils/powerBoostingUtils'; | ||
import { logger } from '../utils/logger'; | ||
|
||
export const fillIncompletePowerSnapshots = async (): Promise<void> => { | ||
const incompletePowerSnapshots = await findInCompletePowerSnapShots(); | ||
logger.debug( | ||
'fillIncompletePowerSnapshots incompletePowerSnapshots', | ||
JSON.stringify(incompletePowerSnapshots, null, 2), | ||
); | ||
for (const powerSnapshot of incompletePowerSnapshots) { | ||
try { | ||
const roundNumber = getRoundNumberByDate(powerSnapshot.time).round; | ||
await updatePowerSnapShots({ | ||
powerSnapshot, | ||
roundNumber, | ||
}); | ||
} catch (e) { | ||
logger.error('fillIncompletePowerSnapshots error', e); | ||
} | ||
} | ||
}; |