Skip to content

Commit

Permalink
add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
justraman committed Mar 7, 2024
1 parent a72dbc8 commit bd29867
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/job-handlers/compute-traits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ export default async (job: Queue.Job<JobData>, done: Queue.DoneCallback) => {
})

if (!traitTypeMap.size) {
job.log(`No traits found for collection ${collectionId}`)
done()

return
}

job.log(`Found ${traitTypeMap.size} trait types`)

const traitsToSave: Trait[] = []

traitTypeMap.forEach((traitValueMap, traitType) => {
Expand All @@ -88,6 +91,8 @@ export default async (job: Queue.Job<JobData>, done: Queue.DoneCallback) => {
})
})

job.log(`Saving ${traitsToSave.length} traits`)

await em.save(Trait, traitsToSave as any, { chunk: 1000 })
const traitTokensToSave: TraitToken[] = []

Expand All @@ -105,6 +110,7 @@ export default async (job: Queue.Job<JobData>, done: Queue.DoneCallback) => {
})

if (traitTokensToSave.length) {
job.log(`Saving ${traitsToSave.length} token traits`)
await em.save(TraitToken, traitTokensToSave as any, { chunk: 1000 })
}

Expand Down
2 changes: 1 addition & 1 deletion src/jobs/compute-traits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { redisConfig } from './common'
export type JobData = { collectionId: string }

export const traitsQueue = new Queue<JobData>('traitsQueue', {
defaultJobOptions: { delay: 2000, attempts: 2, removeOnComplete: true },
defaultJobOptions: { delay: 2000, attempts: 2, removeOnComplete: 100 },
redis: redisConfig,
settings: {
maxStalledCount: 3,
Expand Down

0 comments on commit bd29867

Please sign in to comment.