зеркало из https://github.com/microsoft/ghcrawler.git
change org and team members urn
This commit is contained in:
Родитель
044a34994d
Коммит
0f0acd68a3
|
@ -82,7 +82,7 @@ class GitHubProcessor {
|
|||
//
|
||||
this._addRoot(request, 'user', 'user', document.url.replace('/orgs/', '/users/'), `urn:user:${document.id}`);
|
||||
this._addCollection(request, 'repos', "repo", null, `urn:user:${document.id}:repos`);
|
||||
this._addRelation(request, 'members', "user", document.members_url.replace('{/member}', ''));
|
||||
this._addRelation(request, 'members', "user", document.members_url.replace('{/member}', ''), `${request.getQualifier()}:org_members`);
|
||||
|
||||
return document;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ class GitHubProcessor {
|
|||
request.linkSiblings(`urn:org:${document.organization.id}:teams`);
|
||||
|
||||
this._addRoot(request, 'organization', 'org');
|
||||
this._addRelation(request, 'members', 'user', document.members_url.replace('{/member}', ''));
|
||||
this._addRelation(request, 'members', 'user', document.members_url.replace('{/member}', ''), `${request.getQualifier()}:team_members`);
|
||||
this._addRelation(request, 'repos', 'repo', document.repositories_url);
|
||||
return document;
|
||||
}
|
||||
|
@ -309,8 +309,7 @@ class GitHubProcessor {
|
|||
newRequest.payload = event;
|
||||
return newRequest;
|
||||
});
|
||||
// queue up the discovered new events for immediate fetching
|
||||
request.queue(newRequests, 'immediate');
|
||||
request.queue(newRequests);
|
||||
});
|
||||
request.track(processingPromise);
|
||||
return null;
|
||||
|
@ -597,7 +596,7 @@ class GitHubProcessor {
|
|||
request.linkRelation(name, `${urn}:pages:${guid}`);
|
||||
// Also add an 'knownPages' link to help deal with page clean up.
|
||||
// request.linkCollection('knownPages', `${urn}:pages`);
|
||||
request.queueRoots(name, url, { relation: { origin: request.type, name: name, type: type, guid: guid } });
|
||||
request.queueRoots(name, url, { relation: { origin: request.type, qualifier: urn, type: type, guid: guid } });
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -610,8 +609,8 @@ class GitHubProcessor {
|
|||
const qualifier = request.context.qualifier;
|
||||
request.linkResource('origin', `${qualifier}`);
|
||||
request.linkResource(relation.origin, `${qualifier}`);
|
||||
request.linkSiblings(`${qualifier}:${relation.name}:pages`);
|
||||
request.linkCollection('unique', `${qualifier}:${relation.name}:pages:${relation.guid}`);
|
||||
request.linkSiblings(`${relation.qualifier}:pages`);
|
||||
request.linkCollection('unique', `${relation.qualifier}:pages:${relation.guid}`);
|
||||
const urns = document.elements.map(element => `urn:${relation.type}:${element.id}`);
|
||||
request.linkResource('resources', urns);
|
||||
return document;
|
||||
|
|
|
@ -164,7 +164,7 @@ describe('URN building', () => {
|
|||
expect(teamsRequest.context.qualifier).to.be.equal('urn:repo:42');
|
||||
expect(!!teamsRequest.context.relation.guid).to.be.true;
|
||||
delete teamsRequest.context.relation.guid;
|
||||
expect(teamsRequest.context.relation).to.be.deep.equal({ origin: 'repo', name: 'teams', type: 'team' });
|
||||
expect(teamsRequest.context.relation).to.be.deep.equal({ origin: 'repo', qualifier: 'urn:repo:42:teams', type: 'team' });
|
||||
|
||||
request.crawler.queue.reset();
|
||||
teamsRequest.type = 'teams';
|
||||
|
@ -193,13 +193,13 @@ describe('URN building', () => {
|
|||
expect(membersRequest.context.qualifier).to.be.equal('urn:team:54');
|
||||
expect(!!membersRequest.context.relation.guid).to.be.true;
|
||||
delete membersRequest.context.relation.guid;
|
||||
expect(membersRequest.context.relation).to.be.deep.equal({ name: 'members', origin: 'team', type: 'user' });
|
||||
expect(membersRequest.context.relation).to.be.deep.equal({ qualifier: 'urn:team:54:team_members', origin: 'team', type: 'user' });
|
||||
const reposRequest = request.crawler.queue.getCall(2).args[0];
|
||||
expect(reposRequest.url).to.be.equal('http://team1/repos');
|
||||
expect(reposRequest.context.qualifier).to.be.equal('urn:team:54');
|
||||
expect(!!reposRequest.context.relation.guid).to.be.true;
|
||||
delete reposRequest.context.relation.guid;
|
||||
expect(reposRequest.context.relation).to.be.deep.equal({ name: 'repos', origin: 'team', type: 'repo' });
|
||||
expect(reposRequest.context.relation).to.be.deep.equal({ qualifier: 'urn:team:54:repos', origin: 'team', type: 'repo' });
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -225,7 +225,7 @@ describe('Org processing', () => {
|
|||
siblings: { href: 'urn:orgs', type: 'collection' },
|
||||
user: { href: 'urn:user:9', type: 'resource' },
|
||||
repos: { href: 'urn:user:9:repos', type: 'collection' },
|
||||
members: { href: 'urn:org:9:members:pages:*', type: 'relation' },
|
||||
members: { href: 'urn:org:9:org_members:pages:*', type: 'relation' },
|
||||
}
|
||||
expectLinks(document._metadata.links, links);
|
||||
|
||||
|
@ -860,7 +860,7 @@ describe('Team processing', () => {
|
|||
self: { href: 'urn:team:66', type: 'resource' },
|
||||
siblings: { href: 'urn:org:9:teams', type: 'collection' },
|
||||
organization: { href: 'urn:org:9', type: 'resource' },
|
||||
members: { href: 'urn:team:66:members:pages:*', type: 'relation' },
|
||||
members: { href: 'urn:team:66:team_members:pages:*', type: 'relation' },
|
||||
repos: { href: 'urn:team:66:repos:pages:*', type: 'relation' }
|
||||
}
|
||||
expectLinks(document._metadata.links, links);
|
||||
|
|
Загрузка…
Ссылка в новой задаче