Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
837 B
2
Indexable
Never
const isActive = await this.isAutomationActive(job, Automation.TRACK_IN_PROGRESS_ORDERS);
if (isActive) {
    Logger.log(`Relist jobs is in the queue for user: ${poshmarkUserName}`);
    return;
}

 async isAutomationActive(job: Job, automation: Automation, taskTypes: JobType[] = ['delayed', 'waiting']) {
    const activeJobs = await this.queueManager.getJobsByCredentialsId(
      Queues.POSHMARK,
      job.data.credentialsId,
      taskTypes,
    );
    // If we have active relist jobs, don't add new jobs
    return activeJobs.some((job) => job.data.automation === automation);
  }

 public async getJobsByCredentialsId(queueName: Queues, credentialsId: string, jobTypes: JobType[]) {
    const jobs = await this.getQueue(queueName).getJobs(jobTypes);
    return jobs.filter((job) => job.data.credentialsId === credentialsId);
  }