Commit cc0ba894 authored by Dmitry Vanin's avatar Dmitry Vanin
Browse files

remove methods with private listings

parent 622e68e5
......@@ -7,13 +7,11 @@ const koa = require('koa');
const validate = require('koa-validate');
const Promise = require('bluebird');
const mysql = require('mysql');
const fetch = require('node-fetch');
const tablesNames = require('./constants/tablesNames');
const throwResponseErrorIfNeed = require('./lib/throwResponseErrorIfNeed');
const connectToMySql = require('./lib/connectToMySql');
const lvisEndpoints = require('./lib/lvisEndpoints');
const createTables = require('./lib/createTables');
const logger = require('./lib/logger');
......@@ -56,96 +54,6 @@ class SDK {
return Promise.coroutine(this._run.bind(this))();
}
fetchPrivateListings(feedEndpoint, projectFeedUUID) {
this.logger.log(__filename, 'fetch private listings', feedEndpoint, projectFeedUUID);
return this._fetchPrivateFeed('privateListings', feedEndpoint, projectFeedUUID);
}
fetchPrivateLatestResultsByEventFeedUUID(feedEndpoint, eventFeedUUID) {
this.logger.log(
__filename,
'fetch private latest result by event feed uuid',
feedEndpoint,
eventFeedUUID
);
return this._fetchPrivateFeed('privateLatestResults', feedEndpoint, eventFeedUUID);
}
fetchPrivateAllPublishedElementsByEventFeedUUID(feedEndpoint, eventFeedUUID) {
this.logger.log(
__filename,
'fetch private all publish elements by event feed uuid',
feedEndpoint,
eventFeedUUID
);
return this._fetchPrivateFeed('privateAllPublishedElements', feedEndpoint, eventFeedUUID);
}
fetchPrivateAllElementsByEventFeedUUID(feedEndpoint, eventFeedUUID) {
this.logger.log(
__filename,
'fetch private all elements by event feed uuid',
feedEndpoint,
eventFeedUUID
);
return this._fetchPrivateFeed('privateAllElements', feedEndpoint, eventFeedUUID);
}
fetchPrivateLatestResultsByEventId(feedEndpoint, projectFeedUUID, eventId) {
this.logger.log(
__filename,
'fetch private latest result by event uuid',
feedEndpoint,
projectFeedUUID,
eventId
);
return this._fetchPrivateListingsAndGetEventFeedUUID(
feedEndpoint,
projectFeedUUID,
eventId
).then((eventFeedUUID) =>
this.fetchPrivateLatestResultsByEventFeedUUID(feedEndpoint, eventFeedUUID));
}
fetchPrivateAllPublishedElementsByEventId(feedEndpoint, projectFeedUUID, eventId) {
this.logger.log(
__filename,
'fetch private all publish elements by event uuid',
feedEndpoint,
projectFeedUUID,
eventId
);
return this._fetchPrivateListingsAndGetEventFeedUUID(
feedEndpoint,
projectFeedUUID,
eventId
).then((eventFeedUUID) =>
this.fetchPrivateAllPublishedElementsByEventFeedUUID(feedEndpoint, eventFeedUUID));
}
fetchPrivateAllElementsByEventId(feedEndpoint, projectFeedUUID, eventId) {
this.logger.log(
__filename,
'fetch private all elements by event uuid',
feedEndpoint,
projectFeedUUID,
eventId
);
return this._fetchPrivateListingsAndGetEventFeedUUID(
feedEndpoint,
projectFeedUUID,
eventId
).then((eventFeedUUID) =>
this.fetchPrivateAllElementsByEventFeedUUID(feedEndpoint, eventFeedUUID));
}
* _run() {
yield* connectToMySql.call(this.server.context);
yield* createTables.call(this.server.context);
......@@ -180,29 +88,6 @@ class SDK {
`HTTPS is listening on port: ${this.config.httpsPort}`
);
}
_fetchPrivateFeed(feedName, feedEndpoint, feedUUID) {
const url = lvisEndpoints[feedName](feedEndpoint, this.config.feedVersion, feedUUID);
this.logger.log(__filename, 'fetch private feed', url);
return fetch(url).then((res) => res.json());
}
_fetchPrivateListingsAndGetEventFeedUUID(feedEndpoint, projectFeedUUID, eventId) {
return this.fetchPrivateListings(feedEndpoint, projectFeedUUID).then((listings) =>
SDK._getEventFeedUUIDFromListings(listings, eventId));
}
static _getEventFeedUUIDFromListings(listings, eventId) {
const event = listings.events.find((event) => event.id === eventId);
if (!event) {
throw new Error('event is no found in listings');
}
return event.feed_uuid;
}
}
module.exports = SDK;
'use strict';
const urlJoin = require('url-join');
const privateFeed = (name) =>
(feedEndpoint, version, feedUUID) =>
urlJoin(feedEndpoint, 'feeds', name, version, `${feedUUID}.json`);
module.exports = {
privateListings: privateFeed('listings'),
privateLatestResults: privateFeed('latest_results'),
privateAllPublishedElements: privateFeed('all_published'),
privateAllElements: privateFeed('all'),
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment