MCPcopy Create free account
hub / github.com/0PandaDEV/Ziit / getOrCreateJob

Method getOrCreateJob

server/utils/import-queue.ts:192–218  ·  view source on GitHub ↗
(
    jobId: string,
    userId: string,
    type: "wakatime-api" | "wakatime-file" | "wakapi",
    fileName: string,
    totalToProcess?: number,
  )

Source from the content-addressed store, hash-verified

190 }
191
192 private getOrCreateJob(
193 jobId: string,
194 userId: string,
195 type: "wakatime-api" | "wakatime-file" | "wakapi",
196 fileName: string,
197 totalToProcess?: number,
198 ): ImportJob {
199 let job = activeJobs.get(jobId);
200 if (!job) {
201 job = createInitialImportJob(jobId, userId, type, fileName);
202 if (totalToProcess !== undefined) {
203 job.totalToProcess = totalToProcess;
204 job.processedCount = 0;
205 }
206 activeJobs.set(jobId, job);
207 } else {
208 updateJob(job, {
209 status: ImportStatus.Processing,
210 });
211 if (totalToProcess !== undefined && !job.totalToProcess) {
212 job.totalToProcess = totalToProcess;
213 job.processedCount = 0;
214 activeJobs.set(jobId, job);
215 }
216 }
217 return job;
218 }
219
220 private startWorkers(): void {
221 for (let i = 0; i < this.workerCount; i++) {

Callers 1

processJobMethod · 0.95

Calls 2

createInitialImportJobFunction · 0.85
updateJobFunction · 0.85

Tested by

no test coverage detected