Skip to content

Commit

Permalink
fixed worker
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefs committed Oct 18, 2023
1 parent ab57b74 commit 83c358b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/models/Resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ class ResourceClass {
})
public status!: 'unvisited' | 'done' | 'crawling' | 'error';

@prop({ ref: 'Triple' })
public triples?: Types.DocumentArray<TripleClass>;
@prop({ ref: 'Triple', default: [] })
public triples!: Types.DocumentArray<TripleClass>;

@prop()
public jobId?: number;
Expand Down
3 changes: 2 additions & 1 deletion src/models/Triple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from '@typegoose/typegoose';
import { Document } from 'cheerio';

type TripleSkeleton = Pick<TripleClass, 'subject' | 'predicate' | 'object'>;

@ModelOptions({
schemaOptions: {
timestamps: true,
Expand All @@ -24,7 +26,6 @@ import { Document } from 'cheerio';
@index({ nodes: 1 })
@index({ subject: 1, predicate: 1, object: 1 }, { unique: true })

type TripleSkeleton = Pick<TripleClass, 'subject' | 'predicate' | 'object'>;

class TripleClass {
_id!: mongoose.Types.ObjectId;
Expand Down
2 changes: 1 addition & 1 deletion src/worker/lib/Worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Bluebird from 'bluebird';
import EventEmitter from 'events';
import robotsParser, { Robot } from 'robots-parser';
import * as db from './db';
import { IResource, Resource } from '@derzis/models';
import { Resource } from '@derzis/models';

import Axios from './axios';

Expand Down
4 changes: 2 additions & 2 deletions src/worker/lib/WorkerPubSub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { JobCapacity, JobResult, JobType, Worker } from './Worker';
import { createLogger } from '@derzis/common';
import { MonkeyPatchedLogger } from '@derzis/common';
let log: MonkeyPatchedLogger;
import { IDomain } from '@derzis/models';
import { OngoingJobs } from '@derzis/manager';
import { DomainClass } from 'src/models';

export interface BaseJobRequest {
type: JobType;
Expand All @@ -25,7 +25,7 @@ export interface ResourceCrawlJobRequest extends BaseJobRequest {
url: string;
}
export interface DomainCrawlJobInfo {
domain: IDomain;
domain: DomainClass;
resources: { url: string }[];
}
export type DomainCrawlJobRequest = BaseJobRequest &
Expand Down

0 comments on commit 83c358b

Please sign in to comment.