add stargazers, reviews and tweak collaborators

This commit is contained in:
Jeff McAffer 2017-01-24 19:34:51 -08:00
Родитель 359793e686
Коммит 5c3fdcfcb5
2 изменённых файлов: 23 добавлений и 8 удалений

Просмотреть файл

@ -13,7 +13,7 @@ const uuid = require('node-uuid');
class GitHubProcessor {
constructor(store) {
this.store = store;
this.version = 7;
this.version = 8;
}
process(request) {
@ -180,12 +180,15 @@ class GitHubProcessor {
}
this._addRelation(request, 'teams', 'team');
this._addRelation(request, 'collaborators', 'user', document.collaborators_url.replace('{/collaborator}', ''));
// this._addRelation(request, 'outside_collaborators', 'user', document.collaborators_url.replace('{/collaborator}', '?affiliation=outside'));
// this._addRelation(request, 'collaborators', 'user', document.collaborators_url.replace('{/collaborator}', ''));
this._addRelation(request, 'collaborators', 'user', document.collaborators_url.replace('{/collaborator}', '?affiliation=outside'));
this._addRelation(request, 'contributors', 'user');
if (document.subscribers_count) {
this._addRelation(request, 'subscribers', 'user');
}
if (document.stargazers_count) {
this._addRelation(request, 'stargazers', 'user');
}
this._addCollection(request, 'issues', 'issue', document.issues_url.replace('{/number}', '?state=all'));
this._addCollection(request, 'commits', 'commit', document.commits_url.replace('{/sha}', ''));
this._addCollection(request, 'events', null);
@ -252,6 +255,7 @@ class GitHubProcessor {
}
this._addRoot(request, 'base', 'repo', document.base.repo.url, `urn:repo:${document.base.repo.id}`);
this._addCollection(request, 'reviews', 'review', `${document._links.self.href}/reviews`);
if (document._links.review_comments && document.comments) {
this._addCollection(request, 'review_comments', 'review_comment', document._links.review_comments.href);
}
@ -275,6 +279,17 @@ class GitHubProcessor {
return document;
}
review(request) {
const document = request.document;
const context = request.context;
request.addSelfLink();
request.linkResource('pull_request', context.qualifier);
request.linkSiblings(`${context.qualifier}:reviews`);
this._addRoot(request, 'user', 'user');
return document;
}
review_comment(request) {
// TODO links to consider
// * reactions -- get this by using the following Accept header: application/vnd.github.squirrel-girl-preview
@ -598,7 +613,7 @@ class GitHubProcessor {
isCollectionType(request) {
const collections = new Set([
'collaborators', 'commit_comments', 'commits', 'contributors', 'events', 'issues', 'issue_comments', 'members', 'orgs', 'repos', 'review_comments', 'subscribers', 'statuses', 'teams'
'collaborators', 'commit_comments', 'commits', 'contributors', 'events', 'issues', 'issue_comments', 'members', 'orgs', 'repos', 'reviews', 'review_comments', 'subscribers', 'statuses', 'teams'
]);
return collections.has(request.type);
}

Просмотреть файл

@ -120,14 +120,14 @@ class TraversalPolicy {
return new TraversalPolicy('storageOriginIfMissing', 'version', TraversalPolicy._resolveMapSpec(map));
}
static always(map) {
return new TraversalPolicy('origin', 'always', TraversalPolicy._resolveMapSpec(map));
}
static reprocessAndUpdate(map) {
return new TraversalPolicy('mutables', 'matchOrVersion', TraversalPolicy._resolveMapSpec(map));
}
static always(map) {
return new TraversalPolicy('origin', 'always', TraversalPolicy._resolveMapSpec(map));
}
static clone(policy) {
return new TraversalPolicy(policy.fetch, policy.freshness, policy.map);
}