mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 02:35:08 +02:00
🐛 logging trail for retries
This commit is contained in:
parent
4bdc0b49df
commit
91c545f961
@ -9,17 +9,22 @@ const { notify_discord_of_new_outfit } = require( '../integrations/discord' )
|
|||||||
// ///////////////////////////////
|
// ///////////////////////////////
|
||||||
async function getRocketeerIfOutfitAvailable( id, network='mainnet', retry=false ) {
|
async function getRocketeerIfOutfitAvailable( id, network='mainnet', retry=false ) {
|
||||||
|
|
||||||
|
if( retry ) console.log( `Retry of getRocketeerIfOutfitAvailable for ${ id } on ${ network }` )
|
||||||
|
|
||||||
const newOutfitAllowedInterval = 1000 * 60 * 60 * 24 * 30
|
const newOutfitAllowedInterval = 1000 * 60 * 60 * 24 * 30
|
||||||
|
|
||||||
// Retreive old Rocketeer data
|
// Retreive old Rocketeer data
|
||||||
const rocketeer = await db.collection( `${ network }Rocketeers` ).doc( id ).get().then( dataFromSnap )
|
const rocketeer = await db.collection( `${ network }Rocketeers` ).doc( id ).get().then( dataFromSnap )
|
||||||
|
|
||||||
|
// If this is a retry attempt, skip last change validation
|
||||||
|
if( retry ) return rocketeer
|
||||||
|
|
||||||
// Validate this request
|
// Validate this request
|
||||||
const { value: last_outfit_change } = rocketeer.attributes.find( ( { trait_type } ) => trait_type == "last outfit change" ) || { value: 0 }
|
const { value: last_outfit_change } = rocketeer.attributes.find( ( { trait_type } ) => trait_type == "last outfit change" ) || { value: 0 }
|
||||||
|
|
||||||
// Check whether this Rocketeer is allowed to change
|
// Check whether this Rocketeer is allowed to change
|
||||||
const timeUntilAllowedToChange = newOutfitAllowedInterval - ( Date.now() - last_outfit_change )
|
const timeUntilAllowedToChange = newOutfitAllowedInterval - ( Date.now() - last_outfit_change )
|
||||||
if( !retry && timeUntilAllowedToChange > 0 ) throw new Error( `You changed your outfit too recently, a change is avalable in ${ Math.floor( timeUntilAllowedToChange / ( 1000 * 60 * 60 ) ) } hours (${ new Date( Date.now() + timeUntilAllowedToChange ).toString() })` )
|
if( timeUntilAllowedToChange > 0 ) throw new Error( `You changed your outfit too recently, a change is avalable in ${ Math.floor( timeUntilAllowedToChange / ( 1000 * 60 * 60 ) ) } hours (${ new Date( Date.now() + timeUntilAllowedToChange ).toString() })` )
|
||||||
|
|
||||||
return rocketeer
|
return rocketeer
|
||||||
|
|
||||||
@ -192,6 +197,8 @@ async function handleQueuedRocketeerOutfit( change, context ) {
|
|||||||
const { rocketeerId } = context.params
|
const { rocketeerId } = context.params
|
||||||
const { network, running, address, retry } = change.after.data()
|
const { network, running, address, retry } = change.after.data()
|
||||||
|
|
||||||
|
if( retry ) console.log( `Document change for ${network}QueueOutfitGeneration/${rocketeerId} is a retry attempt` )
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
/////
|
/////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user