From 7051edb212ae98fd14acfff9248dbd87eab03989 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 20 Mar 2018 19:25:35 +0100 Subject: [PATCH 1/8] Added unit tests for testing config file for correct values and if not check the env variables. --- seasoned_api/test/unit/config/testConfig.js | 63 +++++++++++++++++ seasoned_api/test/unit/config/testField.js | 72 ++++++++++++++++++++ seasoned_api/test/unit/config/testFilters.js | 34 +++++++++ 3 files changed, 169 insertions(+) create mode 100644 seasoned_api/test/unit/config/testConfig.js create mode 100644 seasoned_api/test/unit/config/testField.js create mode 100644 seasoned_api/test/unit/config/testFilters.js diff --git a/seasoned_api/test/unit/config/testConfig.js b/seasoned_api/test/unit/config/testConfig.js new file mode 100644 index 0000000..8b08e40 --- /dev/null +++ b/seasoned_api/test/unit/config/testConfig.js @@ -0,0 +1,63 @@ +const assert = require('assert'); +const Config = require('src/config/configuration.js'); + +describe('Config', () => { + before(() => { + this.backedUpEnvironmentVariables = Object.assign({}, process.env); + this.backedUpConfigFields = Object.assign({}, Config.getInstance().fields); + }); + + after(() => { + process.env = this.backedUpEnvironmentVariables; + Config.getInstance().fields = this.backedUpConfigFields; + }); + + it('should retrieve section and option from config file', () => { + Config.getInstance().fields = { 'webserver': { 'port': 1337 } }; + assert.equal(Config.getInstance().get('webserver', 'port'), 1337); + }); + + it('should resolve to environment variables if option is filtered with env', () => { + Config.getInstance().fields = { 'webserver': { 'port': 'env|SEASONED_WEBSERVER_PORT' } }; + process.env.SEASONED_WEBSERVER_PORT = '1338'; + assert.equal(Config.getInstance().get('webserver', 'port'), 1338); + }); + + it('raises an exception if the environment variable does not exist', () => { + Config.getInstance().fields = { 'webserver': { 'port': 'env|DOES_NOT_EXIST' } }; + process.env.SEASONED_WEBSERVER_PORT = '1338'; + assert.throws(() => Config.getInstance().get('webserver', 'port'), /empty/); + }); + + it('raises an exception if the environment variable is empty', () => { + Config.getInstance().fields = { 'webserver': { 'port': 'env|SEASONED_WEBSERVER_PORT' } }; + process.env.SEASONED_WEBSERVER_PORT = ''; + assert.throws(() => Config.getInstance().get('webserver', 'port'), /empty/); + }); + + it('raises an exception if the section does not exist in the file', () => { + Config.getInstance().fields = { 'webserver': { 'port': '1338' } }; + assert.throws(() => Config.getInstance().get('woops', 'port'), /does not exist/); + }); + + it('raises an exception if the option does not exist in the file', () => { + Config.getInstance().fields = { 'webserver': { 'port': '1338' } }; + assert.throws(() => Config.getInstance().get('webserver', 'woops'), /does not exist/); + }); + + it('returns an array if field is an array', () => { + Config.getInstance().fields = { 'bouncer': { 'whitelist': [1, 2, 3] } }; + assert.deepEqual(Config.getInstance().get('bouncer', 'whitelist'), [1, 2, 3]); + }); + + it('decodes field as base64 if base64| is before the variable', () => { + Config.getInstance().fields = { 'webserver': { 'port': 'base64|MTMzOA==' } }; + assert.equal(Config.getInstance().get('webserver', 'port'), 1338); + }); + + it('decodes environment variable as base64 if BASE64= is before the variable', () => { + Config.getInstance().fields = { 'webserver': { 'port': 'env|base64|SEASONED_WEBSERVER_PORT' } }; + process.env.SEASONED_WEBSERVER_PORT = 'MTMzOA=='; + assert.equal(Config.getInstance().get('webserver', 'port'), 1338); + }); +}); diff --git a/seasoned_api/test/unit/config/testField.js b/seasoned_api/test/unit/config/testField.js new file mode 100644 index 0000000..a0449dc --- /dev/null +++ b/seasoned_api/test/unit/config/testField.js @@ -0,0 +1,72 @@ +const assert = require('assert'); +const Field = require('src/config/field.js'); + +describe('Field', () => { + it('should return an array if it is an array', () => { + const field = new Field([1, 2, 3]); + assert.deepEqual(field.value, [1, 2, 3]); + }); + + it('should return the plain value if it is an ordinary field', () => { + const field = new Field('plain value'); + assert.equal(field.value, 'plain value'); + }); + + it('should return false if boolean false is field', () => { + const field = new Field(false); + assert.equal(field.value, false); + }); + + it('should not include any invalid filters', () => { + const field = new Field('invalid-filter|plain value'); + assert.equal(field.value, 'plain value'); + }); + + it('should return the decoded value if it is filtered through base64', () => { + const field = new Field('base64|ZW5jb2RlZCB2YWx1ZQ=='); + assert.equal(field.value, 'encoded value'); + }); + + it('should not decode the value if it missing the filter', () => { + const field = new Field('ZW5jb2RlZCB2YWx1ZQ=='); + assert.equal(field.value, 'ZW5jb2RlZCB2YWx1ZQ=='); + }); + + it('should retrieve the environment variable if env filter is used', () => { + const environmentVariables = { REDIS_URL: 'redis://127.0.0.1:1234' }; + const field = new Field('env|REDIS_URL', environmentVariables); + assert.equal(field.value, 'redis://127.0.0.1:1234'); + }); + + it('should return undefined if the environment variable does not exist', () => { + const environmentVariables = { HTTP_PORT: 8080 }; + const field = new Field('env|REDIS_URL', environmentVariables); + assert.equal(field.value, undefined); + }); + + it('should return undefined if the environment variable is an empty string', () => { + const environmentVariables = { REDIS_URL: '' }; + const field = new Field('env|REDIS_URL', environmentVariables); + assert.deepEqual(field.value, undefined); + }); + + describe('Multiple filters', () => { + it('should decode the environment variable if base64 and env filter are used', () => { + const environmentVariables = { REDIS_URL: 'cmVkaXM6Ly9kYWdibGFkZXQubm8vMTIzNA==' }; + const field = new Field('env|base64|REDIS_URL', environmentVariables); + assert.equal(field.value, 'redis://dagbladet.no/1234'); + }); + + it('should disregard the order of filters when env and base64 are used', () => { + const environmentVariables = { REDIS_URL: 'cmVkaXM6Ly9kYWdibGFkZXQubm8vMTIzNA==' }; + const field = new Field('base64|env|REDIS_URL', environmentVariables); + assert.equal(field.value, 'redis://dagbladet.no/1234'); + }); + + it('should return undefined if both filters are used and env var does not exist', () => { + const environmentVariables = { REDIS_URL: 'cmVkaXM6Ly9kYWdibGFkZXQubm8vMTIzNA==' }; + const field = new Field('base64|env|REDIS_LOL', environmentVariables); + assert.equal(field.value, undefined); + }); + }); +}); diff --git a/seasoned_api/test/unit/config/testFilters.js b/seasoned_api/test/unit/config/testFilters.js new file mode 100644 index 0000000..1218f0d --- /dev/null +++ b/seasoned_api/test/unit/config/testFilters.js @@ -0,0 +1,34 @@ +const assert = require('assert'); +const Filters = require('src/config/filters.js'); + +describe('Filters', () => { + it('should extract base64 as filter if it is at start of string followed by pipe', () => { + const filters = new Filters('base64|'); + assert.deepEqual(filters.filters, ['base64']); + }); + + it('should extract base64 and env as filters if both are separated by pipe', () => { + const filters = new Filters('base64|env|'); + assert.deepEqual(filters.filters, ['base64', 'env']); + }); + + it('should not extract any filters if none are present', () => { + const filters = new Filters('base64'); + assert.deepEqual(filters.filters, []); + }); + + it('should strip env filter from the value', () => { + const filters = new Filters('env|HELLO'); + assert.deepEqual(filters.removeFiltersFromValue(), 'HELLO'); + }); + + it('should strip env and base64 filter from the value', () => { + const filters = new Filters('env|base64|HELLO'); + assert.deepEqual(filters.removeFiltersFromValue(), 'HELLO'); + }); + + it('should strip no filters from the value if there are no filters', () => { + const filters = new Filters('HELLO'); + assert.deepEqual(filters.removeFiltersFromValue(), 'HELLO'); + }); +}); From 9e145f7068b5e92c4aa583ada2c1142d9821f1a8 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 20 Mar 2018 20:12:49 +0100 Subject: [PATCH 2/8] When testing we dont have api access so we create cache entries before each request. The cache key changed so this is now updated in the tests and tmdb. --- seasoned_api/src/config/configuration.js | 2 +- seasoned_api/src/database/database.js | 3 +- seasoned_api/src/tmdb/tmdb.js | 44 ++++++++++--------- .../arrival-info-success-response.json | 13 ++++++ .../system/asAUserIWantToGetPopularMovies.js | 2 +- .../system/asAUserIWantToGetPopularShows.js | 2 +- .../system/asAUserIWantToRequestAMovie.js | 3 ++ ...asAnAnonymousUserIWantToSearchForAMovie.js | 2 +- 8 files changed, 44 insertions(+), 27 deletions(-) create mode 100644 seasoned_api/test/fixtures/arrival-info-success-response.json diff --git a/seasoned_api/src/config/configuration.js b/seasoned_api/src/config/configuration.js index b9eede4..a5c859e 100644 --- a/seasoned_api/src/config/configuration.js +++ b/seasoned_api/src/config/configuration.js @@ -28,7 +28,7 @@ class Config { const field = new Field(this.fields[section][option]); if (field.value === '') { - const envField = process.env[[section.toUpperCase(), option.toUpperCase()].join('_')]; + const envField = process.env[['SEASONED', section.toUpperCase(), option.toUpperCase()].join('_')]; if (envField !== undefined && envField.length !== 0) { return envField; } } diff --git a/seasoned_api/src/database/database.js b/seasoned_api/src/database/database.js index 4497ee0..a696e7f 100644 --- a/seasoned_api/src/database/database.js +++ b/seasoned_api/src/database/database.js @@ -1,8 +1,7 @@ const configuration = require('src/config/configuration').getInstance(); const SqliteDatabase = require('src/database/sqliteDatabase'); -const host = process.env.TESTING ? ':memory:' : configuration.get('database', 'host'); -const database = new SqliteDatabase(host); +const database = new SqliteDatabase(configuration.get('database', 'host')); /** * This module establishes a connection to the database * specified in the confgiuration file. It tries to setup diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index da86ec9..164b495 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -29,6 +29,7 @@ class TMDB { /** * Retrieve a specific movie by id from TMDB. * @param {Number} identifier of the movie you want to retrieve + * @param {String} type filter results by type (default movie). * @returns {Promise} succeeds if movie was found */ lookup(identifier, type = 'movie') { @@ -36,7 +37,7 @@ class TMDB { const cacheKey = `${this.cacheTags.info}:${type}:${identifier}`; return Promise.resolve() .then(() => this.cache.get(cacheKey)) - .catch(() => this.tmdb(this.tmdbMethod('info', type), query)) + .catch(() => this.tmdb(TMDB_METHODS['info'][type]), query)) .catch(() => { throw new Error('Could not find a movie with that id.'); }) .then(response => this.cache.set(cacheKey, response)) .then((response) => { @@ -50,16 +51,18 @@ class TMDB { } /** - * Retrive list of of items from TMDB matching the query and/or type given. - * @param {queryText, page, type} the page number to specify in the request for discover, + * Retrive search results from TMDB. + * @param {String} text query you want to search for + * @param {Number} page representing pagination of results + * @param {String} type filter results by type (default multi) * @returns {Promise} dict with query results, current page and total_pages */ search(text, page = 1, type = 'multi') { - const query = { query: text, page }; + const query = { query: text, page: page }; const cacheKey = `${this.cacheTags.search}:${page}:${type}:${text}`; return Promise.resolve() .then(() => this.cache.get(cacheKey)) - .catch(() => this.tmdb(this.tmdbMethod('search', type), query)) + .catch(() => this.tmdb(TMDB_METHODS['search'][type], query)) .catch(() => { throw new Error('Could not search for movies/shows at tmdb.'); }) .then(response => this.cache.set(cacheKey, response)) .then(response => this.mapResults(response)) @@ -71,18 +74,17 @@ class TMDB { /** * Fetches a given list from tmdb. - * @param {listName} List we want to fetch. - * @param {type} The to specify in the request for discover (default 'movie'). - * @param {id} When finding similar a id can be added to query - * @param {page} Page number we want to fetch. + * @param {String} listName Name of list + * @param {String} type filter results by type (default movie) + * @param {Number} page representing pagination of results * @returns {Promise} dict with query results, current page and total_pages */ - listSearch(listName, type = 'movie', id, page = '1') { - const params = { id, page }; - const cacheKey = `${this.cacheTags[listName]}:${type}:${id}:${page}`; + listSearch(listName, type = 'movie', page = '1') { + const cacheKey = `${this.cacheTags[listName]}:${type}:${page}`; return Promise.resolve() .then(() => this.cache.get(cacheKey)) - .catch(() => this.tmdb(this.tmdbMethod(listName, type), params)) + .catch(() => this.tmdb(TMDB_METHODS[listName][type], page)) + .catch(() => { throw new Error('Error fetching list from tmdb.')}) .then(response => this.cache.set(cacheKey, response)) .then(response => this.mapResults(response, type)) .catch((error) => { throw new Error(error); }) @@ -91,16 +93,10 @@ class TMDB { })); } - tmdbMethod(apiMethod, type) { - const method = TMDB_METHODS[apiMethod][type]; - if (method !== undefined) return method; - throw new Error('Could not find tmdb api method.'); - } - /** * Maps our response from tmdb api to a movie/show object. - * @param {response} JSON response from tmdb. - * @param {type} The type declared in listSearch. + * @param {String} response from tmdb. + * @param {String} The type declared in listSearch. * @returns {Promise} dict with tmdb results, mapped as movie/show objects. */ mapResults(response, type) { @@ -114,6 +110,12 @@ class TMDB { .catch((error) => { throw new Error(error); }); } + /** + * Wraps moviedb library to support Promises. + * @param {String} method function name in the library + * @param {Object} argument argument to function being called + * @returns {Promise} succeeds if callback succeeds + */ tmdb(method, argument) { return new Promise((resolve, reject) => { const callback = (error, reponse) => { diff --git a/seasoned_api/test/fixtures/arrival-info-success-response.json b/seasoned_api/test/fixtures/arrival-info-success-response.json new file mode 100644 index 0000000..eee29ce --- /dev/null +++ b/seasoned_api/test/fixtures/arrival-info-success-response.json @@ -0,0 +1,13 @@ +{ + "background_path": "/yIZ1xendyqKvY3FGeeUYUd5X9Mm.jpg", + "id": 329865, + "popularity": 26.978601, + "poster_path": "/hLudzvGfpi6JlwUnsNhXwKKg4j.jpg", + "release_status": "Released", + "score": 7.3, + "summary": "Taking place after alien crafts land around the world, an expert linguist is recruited by the military to determine whether they come in peace or are a threat.", + "tagline": "Why are they here?", + "title": "Arrival", + "type": "movie", + "year": 2016 +} diff --git a/seasoned_api/test/system/asAUserIWantToGetPopularMovies.js b/seasoned_api/test/system/asAUserIWantToGetPopularMovies.js index 642a84f..d909d73 100644 --- a/seasoned_api/test/system/asAUserIWantToGetPopularMovies.js +++ b/seasoned_api/test/system/asAUserIWantToGetPopularMovies.js @@ -7,7 +7,7 @@ const popularMoviesSuccess = require('test/fixtures/popular-movies-success-respo describe('As a user I want to get popular movies', () => { before(() => resetDatabase()); - before(() => createCacheEntry('p:movie::1', popularMoviesSuccess)); + before(() => createCacheEntry('p:movie:1', popularMoviesSuccess)); it('should return 200 with the information', () => request(app) diff --git a/seasoned_api/test/system/asAUserIWantToGetPopularShows.js b/seasoned_api/test/system/asAUserIWantToGetPopularShows.js index f3e5185..5260235 100644 --- a/seasoned_api/test/system/asAUserIWantToGetPopularShows.js +++ b/seasoned_api/test/system/asAUserIWantToGetPopularShows.js @@ -7,7 +7,7 @@ const popularShowsSuccess = require('test/fixtures/popular-show-success-response describe('As a user I want to get popular shows', () => { before(() => resetDatabase()); - before(() => createCacheEntry('p:show::1', popularShowsSuccess)); + before(() => createCacheEntry('p:show:1', popularShowsSuccess)); it('should return 200 with the information', () => request(app) diff --git a/seasoned_api/test/system/asAUserIWantToRequestAMovie.js b/seasoned_api/test/system/asAUserIWantToRequestAMovie.js index d78ceb4..65b496f 100644 --- a/seasoned_api/test/system/asAUserIWantToRequestAMovie.js +++ b/seasoned_api/test/system/asAUserIWantToRequestAMovie.js @@ -1,14 +1,17 @@ const resetDatabase = require('test/helpers/resetDatabase'); +const createCacheEntry = require('test/helpers/createCacheEntry'); const app = require('src/webserver/app'); const request = require('supertest-as-promised'); const createUser = require('test/helpers/createUser'); const createToken = require('test/helpers/createToken'); +const infoMovieSuccess = require('test/fixtures/arrival-info-success-response.json'); describe('As a user I want to request a movie', () => { before(() => { return resetDatabase() .then(() => createUser('test_user', 'test@gmail.com', 'password')); }) + before(() => createCacheEntry('i:movie:329865', infoMovieSuccess)); it('should return 200 when item is requested', () => request(app) diff --git a/seasoned_api/test/system/asAnAnonymousUserIWantToSearchForAMovie.js b/seasoned_api/test/system/asAnAnonymousUserIWantToSearchForAMovie.js index 360adab..b9b2789 100644 --- a/seasoned_api/test/system/asAnAnonymousUserIWantToSearchForAMovie.js +++ b/seasoned_api/test/system/asAnAnonymousUserIWantToSearchForAMovie.js @@ -6,7 +6,7 @@ const interstellarQuerySuccess = require('test/fixtures/interstellar-query-succe describe('As an anonymous user I want to search for a movie', () => { before(() => resetDatabase()); - before(() => createCacheEntry('s:1:movie:interstellar', interstellarQuerySuccess)); + before(() => createCacheEntry('se:1:multi:interstellar', interstellarQuerySuccess)); it('should return 200 with the search results even if user is not logged in', () => request(app) From 1b08c8d3d101816bf5e4701e5bb0327ca8b78dc3 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 20 Mar 2018 20:14:15 +0100 Subject: [PATCH 3/8] Now when running tests we use a separate config file test.json --- seasoned_api/conf/test.json | 17 +++++++++++++++++ seasoned_api/package.json | 7 +++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 seasoned_api/conf/test.json diff --git a/seasoned_api/conf/test.json b/seasoned_api/conf/test.json new file mode 100644 index 0000000..cc7b8fc --- /dev/null +++ b/seasoned_api/conf/test.json @@ -0,0 +1,17 @@ +{ + "database": { + "host": ":memory:" + }, + "webserver": { + "port": 31400 + }, + "tmdb": { + "apiKey": "bogus-api-key" + }, + "raven": { + "DSN": "" + }, + "authentication": { + "secret": "secret" + } +} diff --git a/seasoned_api/package.json b/seasoned_api/package.json index 383fea4..a56b4db 100644 --- a/seasoned_api/package.json +++ b/seasoned_api/package.json @@ -3,16 +3,19 @@ "main": "webserver/server.js", "scripts": { "start": "cross-env SEASONED_CONFIG=conf/development.json NODE_PATH=. node src/webserver/server.js", - "test": "cross-env SEASONED_CONFIG=conf/development.json TESTING=true NODE_PATH=. mocha --recursive test/system", + "test": "cross-env SEASONED_CONFIG=conf/test.json NODE_PATH=. mocha --recursive test", "coverage": "cross-env SEASONED_CONFIG=conf/test.json NODE_PATH=. istanbul cover -x script/autogenerate-documentation.js --include-all-sources --dir test/.coverage node_modules/mocha/bin/_mocha --recursive test/**/* -- --report lcovonly && cat test/.coverage/lcov.info | coveralls && rm -rf test/.coverage", "lint": "./node_modules/.bin/eslint src/" }, "dependencies": { "bcrypt-nodejs": "^0.0.3", + "blanket": "^1.2.3", "body-parser": "~1.0.1", + "codecov": "^3.0.0", "cross-env": "^3.1.3", "express": "~4.11.0", "jsonwebtoken": "^8.0.1", + "mocha-lcov-reporter": "^1.3.0", "mongoose": "^3.6.13", "moviedb": "^0.2.10", "node-cache": "^4.1.1", @@ -28,7 +31,7 @@ "eslint-config-airbnb-base": "^12.1.0", "eslint-plugin-import": "^2.8.0", "istanbul": "^0.4.5", - "mocha": "^3.1.0", + "mocha": "^5.0.4", "supertest": "^2.0.1", "supertest-as-promised": "^4.0.1" } From 996295b1fe14f9cfa23aceda87bf9a843974f6bd Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 20 Mar 2018 20:14:44 +0100 Subject: [PATCH 4/8] Removed the id parameter, not used. --- seasoned_api/src/webserver/controllers/tmdb/listSearch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seasoned_api/src/webserver/controllers/tmdb/listSearch.js b/seasoned_api/src/webserver/controllers/tmdb/listSearch.js index 103f94c..80e7add 100644 --- a/seasoned_api/src/webserver/controllers/tmdb/listSearch.js +++ b/seasoned_api/src/webserver/controllers/tmdb/listSearch.js @@ -13,8 +13,8 @@ const tmdb = new TMDB(cache, configuration.get('tmdb', 'apiKey')); */ function listSearchController(req, res) { const listname = req.params.listname; - const { type, id, page } = req.query; - tmdb.listSearch(listname, type, id, page) + const { type, page } = req.query; + tmdb.listSearch(listname, type, page) .then((results) => { res.send(results); }).catch((error) => { From 42b8b5ea0e88adc8de2d3cac4eb3bc23e09329a0 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 20 Mar 2018 20:15:28 +0100 Subject: [PATCH 5/8] Removed a ) --- seasoned_api/src/tmdb/tmdb.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index 164b495..4401b49 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -37,7 +37,7 @@ class TMDB { const cacheKey = `${this.cacheTags.info}:${type}:${identifier}`; return Promise.resolve() .then(() => this.cache.get(cacheKey)) - .catch(() => this.tmdb(TMDB_METHODS['info'][type]), query)) + .catch(() => this.tmdb(TMDB_METHODS['info'][type], query)) .catch(() => { throw new Error('Could not find a movie with that id.'); }) .then(response => this.cache.set(cacheKey, response)) .then((response) => { From 18359f442c7dd350c8c3280d866581ef92f4cd09 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 20 Mar 2018 21:17:41 +0100 Subject: [PATCH 6/8] Mapped results in tmdb now returns the complete json object so not needed to be created before sent. When getting all requested movies and shows it is now possible to only get one page at a time. --- seasoned_api/src/plex/requestRepository.js | 12 ++++++------ seasoned_api/src/tmdb/tmdb.js | 15 +++++---------- .../webserver/controllers/plex/fetchRequested.js | 4 ++-- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/seasoned_api/src/plex/requestRepository.js b/seasoned_api/src/plex/requestRepository.js index fefa027..db37207 100644 --- a/seasoned_api/src/plex/requestRepository.js +++ b/seasoned_api/src/plex/requestRepository.js @@ -18,8 +18,8 @@ class RequestRepository { this.queries = { insertRequest: `INSERT INTO requests(id,title,year,poster_path,background_path,requested_by,ip,user_agent,type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, - fetchRequestedItems: 'SELECT * FROM requests ORDER BY date DESC', - fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ?', + fetchRequestedItems: 'SELECT * FROM requests ORDER BY date DESC LIMIT 25 OFFSET ?*25-25', + fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ? DESC LIMIT 25 OFFSET ?*25-25', updateRequestedById: 'UPDATE requests SET status = ? WHERE id is ? AND type is ?', checkIfIdRequested: 'SELECT * FROM requests WHERE id IS ? AND type IS ?', userRequests: 'SELECT * FROM requests WHERE requested_by IS ?' @@ -68,19 +68,19 @@ class RequestRepository { return Promise.resolve() .then(() => tmdb.lookup(identifier, type)) .then((movie) => { - const username = user == undefined ? undefined : user.username; + const username = user === undefined ? undefined : user.username; // Add request to database return this.database.run(this.queries.insertRequest, [movie.id, movie.title, movie.year, movie.poster_path, movie.background_path, username, ip, user_agent, movie.type]); }); } - fetchRequested(status, type = '%') { + fetchRequested(status, page = '1', type = '%') { return Promise.resolve() .then(() => { if (status === 'requested' || status === 'downloading' || status === 'downloaded') - return this.database.all(this.queries.fetchRequestedItemsByStatus, [status, type]); + return this.database.all(this.queries.fetchRequestedItemsByStatus, [status, type, page]); else - return this.database.all(this.queries.fetchRequestedItems); + return this.database.all(this.queries.fetchRequestedItems, page); }) } diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index 4401b49..154f3f7 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -66,10 +66,6 @@ class TMDB { .catch(() => { throw new Error('Could not search for movies/shows at tmdb.'); }) .then(response => this.cache.set(cacheKey, response)) .then(response => this.mapResults(response)) - .catch((error) => { throw new Error(error); }) - .then(([mappedResults, pagenumber, totalpages, total_results]) => ({ - results: mappedResults, page: pagenumber, total_results, total_pages: totalpages, - })); } /** @@ -80,17 +76,15 @@ class TMDB { * @returns {Promise} dict with query results, current page and total_pages */ listSearch(listName, type = 'movie', page = '1') { + const query = { page: page } + console.log(query) const cacheKey = `${this.cacheTags[listName]}:${type}:${page}`; return Promise.resolve() .then(() => this.cache.get(cacheKey)) - .catch(() => this.tmdb(TMDB_METHODS[listName][type], page)) + .catch(() => this.tmdb(TMDB_METHODS[listName][type], query)) .catch(() => { throw new Error('Error fetching list from tmdb.')}) .then(response => this.cache.set(cacheKey, response)) .then(response => this.mapResults(response, type)) - .catch((error) => { throw new Error(error); }) - .then(([mappedResults, pagenumber, totalpages, total_results]) => ({ - results: mappedResults, page: pagenumber, total_pages: totalpages, total_results, - })); } /** @@ -100,12 +94,13 @@ class TMDB { * @returns {Promise} dict with tmdb results, mapped as movie/show objects. */ mapResults(response, type) { + console.log(response.page) return Promise.resolve() .then(() => { const mappedResults = response.results.filter((element) => { return (element.media_type === 'movie' || element.media_type === 'tv' || element.media_type === undefined); }).map((element) => convertTmdbToSeasoned(element, type)); - return [mappedResults, response.page, response.total_pages, response.total_results]; + return {results: mappedResults, page: response.page, total_pages: response.total_pages, total_results: response.total_results} }) .catch((error) => { throw new Error(error); }); } diff --git a/seasoned_api/src/webserver/controllers/plex/fetchRequested.js b/seasoned_api/src/webserver/controllers/plex/fetchRequested.js index f216396..cd0f842 100644 --- a/seasoned_api/src/webserver/controllers/plex/fetchRequested.js +++ b/seasoned_api/src/webserver/controllers/plex/fetchRequested.js @@ -10,9 +10,9 @@ const requestRepository = new RequestRepository(); */ function fetchRequestedController(req, res) { // const user = req.loggedInUser; - const { status } = req.query; + const { status, page } = req.query; - requestRepository.fetchRequested(status) + requestRepository.fetchRequested(status, page) .then((requestedItems) => { res.send({ success: true, results: requestedItems, total_results: requestedItems.length }); }) From 8e22b0f6eaf10fb33e7499c74b131ae2b57c8b0d Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Tue, 20 Mar 2018 21:18:11 +0100 Subject: [PATCH 7/8] Updated fixtures. --- .../popular-movies-success-response.json | 228 +++++++++++++++++- .../popular-show-success-response.json | 228 +++++++++++++++++- 2 files changed, 454 insertions(+), 2 deletions(-) diff --git a/seasoned_api/test/fixtures/popular-movies-success-response.json b/seasoned_api/test/fixtures/popular-movies-success-response.json index 30b8e5c..d6c5f9d 100644 --- a/seasoned_api/test/fixtures/popular-movies-success-response.json +++ b/seasoned_api/test/fixtures/popular-movies-success-response.json @@ -1 +1,227 @@ -{"results":[{"title":"The Maze Runner","year":2014,"type":"movie","id":198663,"summary":"Set in a post-apocalyptic world, young Thomas is deposited in a community of boys after his memory is erased, soon learning they're all trapped in a maze that will require him to join forces with fellow “runners” for a shot at escape.","poster_path":"/coss7RgL0NH6g4fC2s5atvf3dFO.jpg","background_path":"/lkOZcsXcOLZYeJ2YxJd3vSldvU4.jpg","popularity":435.990884,"score":7},{"title":"Blade Runner 2049","year":2017,"type":"movie","id":335984,"summary":"Thirty years after the events of the first film, a new blade runner, LAPD Officer K, unearths a long-buried secret that has the potential to plunge what's left of society into chaos. K's discovery leads him on a quest to find Rick Deckard, a former LAPD blade runner who has been missing for 30 years.","poster_path":"/gajva2L0rPYkEWjzgFlBXCAVBE5.jpg","background_path":"/mVr0UiqyltcfqxbAUcLl9zWL8ah.jpg","popularity":375.70732,"score":7.4},{"title":"Coco","year":2017,"type":"movie","id":354912,"summary":"Despite his family’s baffling generations-old ban on music, Miguel dreams of becoming an accomplished musician like his idol, Ernesto de la Cruz. Desperate to prove his talent, Miguel finds himself in the stunning and colorful Land of the Dead following a mysterious chain of events. Along the way, he meets charming trickster Hector, and together, they set off on an extraordinary journey to unlock the real story behind Miguel's family history.","poster_path":"/eKi8dIrr8voobbaGzDpe8w0PVbC.jpg","background_path":"/askg3SMvhqEl4OL52YuvdtY40Yb.jpg","popularity":373.720653,"score":7.7},{"title":"It","year":2017,"type":"movie","id":346364,"summary":"In a small town in Maine, seven children known as The Losers Club come face to face with life problems, bullies and a monster that takes the shape of a clown called Pennywise.","poster_path":"/9E2y5Q7WlCVNEhP5GiVTjhEhx1o.jpg","background_path":"/tcheoA2nPATCm2vvXw2hVQoaEFD.jpg","popularity":372.536196,"score":7.1},{"title":"Jumanji","year":1995,"type":"movie","id":8844,"summary":"When siblings Judy and Peter discover an enchanted board game that opens the door to a magical world, they unwittingly invite Alan -- an adult who's been trapped inside the game for 26 years -- into their living room. Alan's only hope for freedom is to finish the game, which proves risky as all three find themselves running from giant rhinoceroses, evil monkeys and other terrifying creatures.","poster_path":"/8wBKXZNod4frLZjAKSDuAcQ2dEU.jpg","background_path":"/7k4zEgUZbzMHawDaMc9yIkmY1qR.jpg","popularity":328.104005,"score":7},{"title":"Sleight","year":2017,"type":"movie","id":347882,"summary":"A young street magician is left to take care of his little sister after his mother's passing and turns to drug dealing in the Los Angeles party scene to keep a roof over their heads. When he gets into trouble with his supplier, his sister is kidnapped and he is forced to rely on both his sleight of hand and brilliant mind to save her.","poster_path":"/wridRvGxDqGldhzAIh3IcZhHT5F.jpg","background_path":"/2SEgJ0mHJ7TSdVDbkGU061tR33K.jpg","popularity":313.194105,"score":5.2},{"title":"Thor: Ragnarok","year":2017,"type":"movie","id":284053,"summary":"Thor is imprisoned on the other side of the universe and finds himself in a race against time to get back to Asgard to stop Ragnarok, the prophecy of destruction to his homeworld and the end of Asgardian civilization, at the hands of an all-powerful new threat, the ruthless Hela.","poster_path":"/oSLd5GYGsiGgzDPKTwQh7wamO8t.jpg","background_path":"/kaIfm5ryEOwYg8mLbq8HkPuM1Fo.jpg","popularity":275.821051,"score":7.5},{"title":"War for the Planet of the Apes","year":2017,"type":"movie","id":281338,"summary":"Caesar and his apes are forced into a deadly conflict with an army of humans led by a ruthless Colonel. After the apes suffer unimaginable losses, Caesar wrestles with his darker instincts and begins his own mythic quest to avenge his kind. As the journey finally brings them face to face, Caesar and the Colonel are pitted against each other in an epic battle that will determine the fate of both their species and the future of the planet.","poster_path":"/3vYhLLxrTtZLysXtIWktmd57Snv.jpg","background_path":"/ulMscezy9YX0bhknvJbZoUgQxO5.jpg","popularity":256.86709,"score":6.8},{"title":"Olaf's Frozen Adventure","year":2017,"type":"movie","id":460793,"summary":"Olaf is on a mission to harness the best holiday traditions for Anna, Elsa, and Kristoff.","poster_path":"/47pLZ1gr63WaciDfHCpmoiXJlVr.jpg","background_path":"/9K4QqQZg4TVXcxBGDiVY4Aey3Rn.jpg","popularity":255.47965,"score":5.9},{"title":"Minions","year":2015,"type":"movie","id":211672,"summary":"Minions Stuart, Kevin and Bob are recruited by Scarlet Overkill, a super-villain who, alongside her inventor husband Herb, hatches a plot to take over the world.","poster_path":"/q0R4crx2SehcEEQEkYObktdeFy.jpg","background_path":"/qLmdjn2fv0FV2Mh4NBzMArdA0Uu.jpg","popularity":211.499685,"score":6.4},{"title":"Baby Driver","year":2017,"type":"movie","id":339403,"summary":"After being coerced into working for a crime boss, a young getaway driver finds himself taking part in a heist doomed to fail.","poster_path":"/dN9LbVNNZFITwfaRjl4tmwGWkRg.jpg","background_path":"/goCvLSUFz0p7k8R10Hv4CVh3EQv.jpg","popularity":208.126298,"score":7.3},{"title":"Batman v Superman: Dawn of Justice","year":2016,"type":"movie","id":209112,"summary":"Fearing the actions of a god-like Super Hero left unchecked, Gotham City’s own formidable, forceful vigilante takes on Metropolis’s most revered, modern-day savior, while the world wrestles with what sort of hero it really needs. And with Batman and Superman at war with one another, a new threat quickly arises, putting mankind in greater danger than it’s ever known before.","poster_path":"/cGOPbv9wA5gEejkUN892JrveARt.jpg","background_path":"/vsjBeMPZtyB7yNsYY56XYxifaQZ.jpg","popularity":186.4518,"score":5.7},{"title":"Pirates of the Caribbean: Dead Men Tell No Tales","year":2017,"type":"movie","id":166426,"summary":"Thrust into an all-new adventure, a down-on-his-luck Capt. Jack Sparrow feels the winds of ill-fortune blowing even more strongly when deadly ghost sailors led by his old nemesis, the evil Capt. Salazar, escape from the Devil's Triangle. Jack's only hope of survival lies in seeking out the legendary Trident of Poseidon, but to find it, he must forge an uneasy alliance with a brilliant and beautiful astronomer and a headstrong young man in the British navy.","poster_path":"/xbpSDU3p7YUGlu9Mr6Egg2Vweto.jpg","background_path":"/7C921eWK06n12c1miRXnYoEu5Yv.jpg","popularity":177.161496,"score":6.5},{"title":"Valerian and the City of a Thousand Planets","year":2017,"type":"movie","id":339964,"summary":"In the 28th century, Valerian and Laureline are special operatives charged with keeping order throughout the human territories. On assignment from the Minister of Defense, the two undertake a mission to Alpha, an ever-expanding metropolis where species from across the universe have converged over centuries to share knowledge, intelligence, and cultures. At the center of Alpha is a mysterious dark force which threatens the peaceful existence of the City of a Thousand Planets, and Valerian and Laureline must race to identify the menace and safeguard not just Alpha, but the future of the universe.","poster_path":"/jfIpMh79fGRqYJ6PwZLCntzgxlF.jpg","background_path":"/7WjMTRF6LDa4latRUIDM25xnDO0.jpg","popularity":175.858459,"score":6.6},{"title":"John Wick","year":2014,"type":"movie","id":245891,"summary":"Ex-hitman John Wick comes out of retirement to track down the gangsters that took everything from him.","poster_path":"/5vHssUeVe25bMrof1HyaPyWgaP.jpg","background_path":"/umC04Cozevu8nn3JTDJ1pc7PVTn.jpg","popularity":171.559878,"score":7},{"title":"Geostorm","year":2017,"type":"movie","id":274855,"summary":"After an unprecedented series of natural disasters threatened the planet, the world's leaders came together to create an intricate network of satellites to control the global climate and keep everyone safe. But now, something has gone wrong: the system built to protect Earth is attacking it, and it becomes a race against the clock to uncover the real threat before a worldwide geostorm wipes out everything and everyone along with it.","poster_path":"/nrsx0jEaBgXq4PWo7SooSnYJTv.jpg","background_path":"/6jrMdMe4sMygTcJPpQTjKPmP4l0.jpg","popularity":159.899247,"score":5.7},{"title":"Beauty and the Beast","year":2017,"type":"movie","id":321612,"summary":"A live-action adaptation of Disney's version of the classic tale of a cursed prince and a beautiful young woman who helps him break the spell.","poster_path":"/tWqifoYuwLETmmasnGHO7xBjEtt.jpg","background_path":"/6aUWe0GSl69wMTSWWexsorMIvwU.jpg","popularity":156.774587,"score":6.8},{"title":"The Hunger Games: Mockingjay - Part 1","year":2014,"type":"movie","id":131631,"summary":"Katniss Everdeen reluctantly becomes the symbol of a mass rebellion against the autocratic Capitol.","poster_path":"/gj282Pniaa78ZJfbaixyLXnXEDI.jpg","background_path":"/4PwyB0ErucIANzW24Kori71J6gU.jpg","popularity":148.551513,"score":6.7},{"title":"Star Wars: The Last Jedi","year":2017,"type":"movie","id":181808,"summary":"Rey develops her newly discovered abilities with the guidance of Luke Skywalker, who is unsettled by the strength of her powers. Meanwhile, the Resistance prepares to do battle with the First Order.","poster_path":"/kOVEVeg59E0wsnXmF9nrh6OmWII.jpg","background_path":"/5Iw7zQTHVRBOYpA0V6z0yypOPZh.jpg","popularity":144.320581,"score":7.2},{"title":"John Wick: Chapter 2","year":2017,"type":"movie","id":324552,"summary":"John Wick is forced out of retirement by a former associate looking to seize control of a shadowy international assassins’ guild. Bound by a blood oath to aid him, Wick travels to Rome and does battle against some of the world’s most dangerous killers.","poster_path":"/zkXnKIwX5pYorKJp2fjFSfNyKT0.jpg","background_path":"/dQ6s3Ud2KoOs3LKw6xgZr1cw7Yq.jpg","popularity":137.808961,"score":6.8}],"page":1,"total_pages":988,"total_results":19757} \ No newline at end of file +{ + "page": 1, + "results": [ + { + "background_path": "/9ywA15OAiwjSTvg3cBs9B7kOCBF.jpg", + "id": 337167, + "popularity": 620.073793, + "poster_path": "/jjPJ4s3DWZZvI4vw8Xfi4Vqa1Q8.jpg", + "score": 6.2, + "summary": "Believing they have left behind shadowy figures from their past, newlyweds Christian and Ana fully embrace an inextricable connection and shared life of luxury. But just as she steps into her role as Mrs. Grey and he relaxes into an unfamiliar stability, new threats could jeopardize their happy ending before it even begins.", + "title": "Fifty Shades Freed", + "type": "movie", + "year": 2018 + }, + { + "background_path": "/mhdeE1yShHTaDbJVdWyTlzFvNkr.jpg", + "id": 269149, + "popularity": 375.524444, + "poster_path": "/sM33SANp9z6rXW8Itn7NnG1GOEs.jpg", + "score": 7.7, + "summary": "Determined to prove herself, Officer Judy Hopps, the first bunny on Zootopia's police force, jumps at the chance to crack her first case - even if it means partnering with scam-artist fox Nick Wilde to solve the mystery.", + "title": "Zootopia", + "type": "movie", + "year": 2016 + }, + { + "background_path": "/b6ZJZHUdMEFECvGiDpJjlfUWela.jpg", + "id": 284054, + "popularity": 327.127873, + "poster_path": "/uxzzxijgPIY7slzFvMotPv8wjKA.jpg", + "score": 7.4, + "summary": "After the events of Captain America: Civil War, King T'Challa returns home to the reclusive, technologically advanced African nation of Wakanda to serve as his country's new leader. However, T'Challa soon finds that he is challenged for the throne from factions within his own country. When two foes conspire to destroy Wakanda, the hero known as Black Panther must team up with C.I.A. agent Everett K. Ross and members of the Dora Milaje, Wakandan special forces, to prevent Wakanda from being dragged into a world war.", + "title": "Black Panther", + "type": "movie", + "year": 2018 + }, + { + "background_path": "/c4Dw37VZjBmObmJw9bmt8IDwMZH.jpg", + "id": 181808, + "popularity": 231.685892, + "poster_path": "/kOVEVeg59E0wsnXmF9nrh6OmWII.jpg", + "score": 7.2, + "summary": "Rey develops her newly discovered abilities with the guidance of Luke Skywalker, who is unsettled by the strength of her powers. Meanwhile, the Resistance prepares to do battle with the First Order.", + "title": "Star Wars: The Last Jedi", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/askg3SMvhqEl4OL52YuvdtY40Yb.jpg", + "id": 354912, + "popularity": 228.556797, + "poster_path": "/eKi8dIrr8voobbaGzDpe8w0PVbC.jpg", + "score": 7.8, + "summary": "Despite his family’s baffling generations-old ban on music, Miguel dreams of becoming an accomplished musician like his idol, Ernesto de la Cruz. Desperate to prove his talent, Miguel finds himself in the stunning and colorful Land of the Dead following a mysterious chain of events. Along the way, he meets charming trickster Hector, and together, they set off on an extraordinary journey to unlock the real story behind Miguel's family history.", + "title": "Coco", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/rgyhSn3mINvkuy9iswZK0VLqQO3.jpg", + "id": 399055, + "popularity": 192.900926, + "poster_path": "/k4FwHlMhuRR5BISY2Gm2QZHlH5Q.jpg", + "score": 7.4, + "summary": "An other-worldly story, set against the backdrop of Cold War era America circa 1962, where a mute janitor working at a lab falls in love with an amphibious man being held captive there and devises a plan to help him escape.", + "title": "The Shape of Water", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/kaIfm5ryEOwYg8mLbq8HkPuM1Fo.jpg", + "id": 284053, + "popularity": 188.734084, + "poster_path": "/rzRwTcFvttcN1ZpX2xv4j3tSdJu.jpg", + "score": 7.4, + "summary": "Thor is imprisoned on the other side of the universe and finds himself in a race against time to get back to Asgard to stop Ragnarok, the prophecy of destruction to his homeworld and the end of Asgardian civilization, at the hands of an all-powerful new threat, the ruthless Hela.", + "title": "Thor: Ragnarok", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/bLJTjfbZ1c5zSNiAvGYs1Uc82ir.jpg", + "id": 338970, + "popularity": 172.766878, + "poster_path": "/ePyN2nX9t8SOl70eRW47Q29zUFO.jpg", + "score": 6.2, + "summary": "Lara Croft, the fiercely independent daughter of a missing adventurer, must push herself beyond her limits when she finds herself on the island where her father disappeared.", + "title": "Tomb Raider", + "type": "movie", + "year": 2018 + }, + { + "background_path": "/o5T8rZxoWSBMYwjsUFUqTt6uMQB.jpg", + "id": 141052, + "popularity": 153.290379, + "poster_path": "/eifGNCSDuxJeS1loAXil5bIGgvC.jpg", + "score": 6.4, + "summary": "Fuelled by his restored faith in humanity and inspired by Superman's selfless act, Bruce Wayne and Diana Prince assemble a team of metahumans consisting of Barry Allen, Arthur Curry and Victor Stone to face the catastrophic threat of Steppenwolf and the Parademons who are on the hunt for three Mother Boxes on Earth.", + "title": "Justice League", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/gZF2EfM8ov834pCzRpt1xt01SUy.jpg", + "id": 394823, + "popularity": 138.469508, + "poster_path": "/x97gjhJW6X2fus5Q4zhgCe48LYr.jpg", + "score": 4.6, + "summary": "One day, robot Robby enters into a life of the most creative little boy, Toby. Robby had been separated from his robot parents when his spaceship crashed. Toby decides to offer his help and the two of them become friends.", + "title": "Robby and Toby's Fantastic Voyager", + "type": "movie", + "year": 2016 + }, + { + "background_path": "/4QrbczSQGZQA7BG9xMhccQI7LHm.jpg", + "id": 499772, + "popularity": 136.803208, + "poster_path": "/uGntNjUx6YAzbVy7RDgxWnWsdet.jpg", + "score": 5.5, + "summary": "The story of Jesse and Celeste who meets at an unexpected time in their lives. They then realize their names are the same as the characters in the popular break-up romantic comedy, Celeste and Jesse Forever.", + "title": "Meet Me In St. Gallen", + "type": "movie", + "year": 2018 + }, + { + "background_path": "/2SEgJ0mHJ7TSdVDbkGU061tR33K.jpg", + "id": 347882, + "popularity": 125.184868, + "poster_path": "/wridRvGxDqGldhzAIh3IcZhHT5F.jpg", + "score": 5.2, + "summary": "A young street magician is left to take care of his little sister after his mother's passing and turns to drug dealing in the Los Angeles party scene to keep a roof over their heads. When he gets into trouble with his supplier, his sister is kidnapped and he is forced to rely on both his sleight of hand and brilliant mind to save her.", + "title": "Sleight", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/6aUWe0GSl69wMTSWWexsorMIvwU.jpg", + "id": 321612, + "popularity": 121.462615, + "poster_path": "/tWqifoYuwLETmmasnGHO7xBjEtt.jpg", + "score": 6.8, + "summary": "A live-action adaptation of Disney's version of the classic tale of a cursed prince and a beautiful young woman who helps him break the spell.", + "title": "Beauty and the Beast", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/gDbNf0JpmG46fFTHJIPdFga9RRg.jpg", + "id": 300668, + "popularity": 113.297986, + "poster_path": "/d3qcpfNwbAMCNqWDHzPQsUYiUgS.jpg", + "score": 6.5, + "summary": "A biologist signs up for a dangerous, secret expedition into a mysterious zone where the laws of nature don't apply.", + "title": "Annihilation", + "type": "movie", + "year": 2018 + }, + { + "background_path": "/lkOZcsXcOLZYeJ2YxJd3vSldvU4.jpg", + "id": 198663, + "popularity": 109.304464, + "poster_path": "/coss7RgL0NH6g4fC2s5atvf3dFO.jpg", + "score": 7, + "summary": "Set in a post-apocalyptic world, young Thomas is deposited in a community of boys after his memory is erased, soon learning they're all trapped in a maze that will require him to join forces with fellow “runners” for a shot at escape.", + "title": "The Maze Runner", + "type": "movie", + "year": 2014 + }, + { + "background_path": "/rz3TAyd5kmiJmozp3GUbYeB5Kep.jpg", + "id": 353486, + "popularity": 105.483862, + "poster_path": "/bXrZ5iHBEjH7WMidbUDQ0U2xbmr.jpg", + "score": 6.5, + "summary": "The tables are turned as four teenagers are sucked into Jumanji's world - pitted against rhinos, black mambas and an endless variety of jungle traps and puzzles. To survive, they'll play as characters from the game.", + "title": "Jumanji: Welcome to the Jungle", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/mVr0UiqyltcfqxbAUcLl9zWL8ah.jpg", + "id": 335984, + "popularity": 100.275711, + "poster_path": "/gajva2L0rPYkEWjzgFlBXCAVBE5.jpg", + "score": 7.3, + "summary": "Thirty years after the events of the first film, a new blade runner, LAPD Officer K, unearths a long-buried secret that has the potential to plunge what's left of society into chaos. K's discovery leads him on a quest to find Rick Deckard, a former LAPD blade runner who has been missing for 30 years.", + "title": "Blade Runner 2049", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/3L5gfIKt2RK9vnCiLgWTAzkhQWC.jpg", + "id": 396422, + "popularity": 98.340797, + "poster_path": "/tb86j8jVCVsdZnzf8I6cIi65IeM.jpg", + "score": 6.4, + "summary": "Several years after the tragic death of their little girl, a dollmaker and his wife welcome a nun and several girls from a shuttered orphanage into their home, soon becoming the target of the dollmaker's possessed creation, Annabelle.", + "title": "Annabelle: Creation", + "type": "movie", + "year": 2017 + }, + { + "background_path": "/umC04Cozevu8nn3JTDJ1pc7PVTn.jpg", + "id": 245891, + "popularity": 88.622619, + "poster_path": "/5vHssUeVe25bMrof1HyaPyWgaP.jpg", + "score": 7, + "summary": "Ex-hitman John Wick comes out of retirement to track down the gangsters that took everything from him.", + "title": "John Wick", + "type": "movie", + "year": 2014 + }, + { + "background_path": "/9K4QqQZg4TVXcxBGDiVY4Aey3Rn.jpg", + "id": 460793, + "popularity": 88.332911, + "poster_path": "/As8WTtxXs9e3cBit3ztTf7zoRmm.jpg", + "score": 5.9, + "summary": "Olaf is on a mission to harness the best holiday traditions for Anna, Elsa, and Kristoff.", + "title": "Olaf's Frozen Adventure", + "type": "movie", + "year": 2017 + } + ], + "total_pages": 995, + "total_results": 19889 +} \ No newline at end of file diff --git a/seasoned_api/test/fixtures/popular-show-success-response.json b/seasoned_api/test/fixtures/popular-show-success-response.json index 4faebbb..2163c1d 100644 --- a/seasoned_api/test/fixtures/popular-show-success-response.json +++ b/seasoned_api/test/fixtures/popular-show-success-response.json @@ -1 +1,227 @@ -{"results":[{"title":"The Flash","year":2014,"type":"show","id":60735,"summary":"After a particle accelerator causes a freak storm, CSI Investigator Barry Allen is struck by lightning and falls into a coma. Months later he awakens with the power of super speed, granting him the ability to move through Central City like an unseen guardian angel. Though initially excited by his newfound powers, Barry is shocked to discover he is not the only \"meta-human\" who was created in the wake of the accelerator explosion -- and not everyone is using their new powers for good. Barry partners with S.T.A.R. Labs and dedicates his life to protect the innocent. For now, only a few close friends and associates know that Barry is literally the fastest man alive, but it won't be long before the world learns what Barry Allen has become...The Flash.","poster_path":"/lUFK7ElGCk9kVEryDJHICeNdmd1.jpg","background_path":"/mmxxEpTqVdwBlu5Pii7tbedBkPC.jpg","popularity":206.43201,"score":6.8},{"title":"The Big Bang Theory","year":2007,"type":"show","id":1418,"summary":"The Big Bang Theory is centered on five characters living in Pasadena, California: roommates Leonard Hofstadter and Sheldon Cooper; Penny, a waitress and aspiring actress who lives across the hall; and Leonard and Sheldon's equally geeky and socially awkward friends and co-workers, mechanical engineer Howard Wolowitz and astrophysicist Raj Koothrappali. The geekiness and intellect of the four guys is contrasted for comic effect with Penny's social skills and common sense.","poster_path":"/ooBGRQBdbGzBxAVfExiO8r7kloA.jpg","background_path":"/nGsNruW3W27V6r4gkyc3iiEGsKR.jpg","popularity":198.249769,"score":6.9},{"title":"The Face of Analia","year":2008,"type":"show","id":7859,"summary":"El Rostro de Analía is a Spanish-language telenovela produced by the American-based television network Telemundo. It stars Elizabeth Gutiérrez, Martin Karpan, Maritza Rodríguez and Gabriel Porras, with the special appearance of Gaby Espino. Written by Venezuelan writer Humberto \"Kiko\" Olivieri, the story is loosely based on María, María which starred Alba Roversi and Mexican soap star Arturo Peniche in Venezuela, and was also written by Olivieri. The novela is directed by David Posada and Danny Gaviria; with Jairo Arcila as General Producer and Aurelio Valcarcel Carrol as Executive Producer. Although the novela was set in Los Angeles, Telemundo filmed the serial in Miami, Fl. Through [sometimes not so] careful editing it was made to appear as Los Angeles. The network debuted it on October 20, 2008 at the 9 pm timeslot. Telemundo added English subtitles as closed captions on CC3 starting in March.\n\nRTV Pink started to air this telenovela on January 5, 2009 in Serbia. TVN started to air the telenovela on January 19, 2009 at the 8 pm timeslot. It debuted with the highest rating of a 2009 show in Panama. BTV started to air this telenovela on February 2, 2009 in Bulgaria. On February 25, 2009 it also debuted at 8pm on Canal 7 in Guatemala. From 31 August 2009, TV Puls plans to issue El Rostro de Analía on their TV channel in Poland at 15:30. In Albania, Top Channel airs the telenovela from Monday to Friday at 18:30. The show is airing on TV Doma in Slovakia from January 4, 2010 from Monday to Thursday at 20.50 as Pravá tvár vášne, in Romania from April 12, 2010 from Monday to Thursday at 21.30 as Cealalta fata an Analiei;from August 9 will be aired from Monday to Friday at 21.30. From 17 February 2010 RTL Croatia airs this telenovela from Monday to Friday at 14:00 as Drugo lice.","poster_path":"/mQJmZpHjKTsqt64PPGucObvU1gy.jpg","background_path":"/hQov6yy9ZHnM138UzJPvg9O018X.jpg","popularity":125.31485,"score":3.5},{"title":"Mindhunter","year":2017,"type":"show","id":67744,"summary":"An agent in the FBI's Elite Serial Crime Unit develops profiling techniques as he pursues notorious serial killers and rapists.","poster_path":"/zVuc3Sfs6gyJm6M6Iq52jqdavw4.jpg","background_path":"/a906PH7CDmSOdS7kmnAgdWk5mhv.jpg","popularity":122.613557,"score":7.4},{"title":"Supernatural","year":2005,"type":"show","id":1622,"summary":"When they were boys, Sam and Dean Winchester lost their mother to a mysterious and demonic supernatural force. Subsequently, their father raised them to be soldiers. He taught them about the paranormal evil that lives in the dark corners and on the back roads of America ... and he taught them how to kill it. Now, the Winchester brothers crisscross the country in their '67 Chevy Impala, battling every kind of supernatural threat they encounter along the way. ","poster_path":"/pui1V389cQft0BVFu9pbsYLEW1Q.jpg","background_path":"/o9OKe3M06QMLOzTl3l6GStYtnE9.jpg","popularity":122.131552,"score":7.2},{"title":"Arrow","year":2012,"type":"show","id":1412,"summary":"Spoiled billionaire playboy Oliver Queen is missing and presumed dead when his yacht is lost at sea. He returns five years later a changed man, determined to clean up the city as a hooded vigilante armed with a bow.","poster_path":"/mo0FP1GxOFZT4UDde7RFDz5APXF.jpg","background_path":"/dKxkwAJfGuznW8Hu0mhaDJtna0n.jpg","popularity":110.026609,"score":6},{"title":"Money Heist","year":2017,"type":"show","id":71446,"summary":"Spanish television series whose plot revolves around the perfect bank robbery - in this case, not only a bank, but the National Coinage and Stamp Factory, the Royal Mint of Spain.","poster_path":"/tADQv2ujTDMbiijSM4JELrY9tnF.jpg","background_path":"/wiBynY4ZUsklLlMlIQrFQoxByKu.jpg","popularity":106.835487,"score":7.9},{"title":"The Walking Dead","year":2010,"type":"show","id":1402,"summary":"Sheriff's deputy Rick Grimes awakens from a coma to find a post-apocalyptic world dominated by flesh-eating zombies. He sets out to find his family and encounters many other survivors along the way.","poster_path":"/vxuoMW6YBt6UsxvMfRNwRl9LtWS.jpg","background_path":"/xVzvD5BPAU4HpleFSo8QOdHkndo.jpg","popularity":103.579571,"score":7.4},{"title":"Marvel's Agents of S.H.I.E.L.D.","year":2013,"type":"show","id":1403,"summary":"Agent Phil Coulson of S.H.I.E.L.D. (Strategic Homeland Intervention, Enforcement and Logistics Division) puts together a team of agents to investigate the new, the strange and the unknown around the globe, protecting the ordinary from the extraordinary.","poster_path":"/xjm6uVktPuKXNILwjLXwVG5d5BU.jpg","background_path":"/qtr5i6hOm6oVzTYl3jOQAYP3oc7.jpg","popularity":100.53945,"score":6.7},{"title":"The Simpsons","year":1989,"type":"show","id":456,"summary":"Set in Springfield, the average American town, the show focuses on the antics and everyday adventures of the Simpson family; Homer, Marge, Bart, Lisa and Maggie, as well as a virtual cast of thousands. Since the beginning, the series has been a pop culture icon, attracting hundreds of celebrities to guest star. The show has also made name for itself in its fearless satirical take on politics, media and American life in general.","poster_path":"/yTZQkSsxUFJZJe67IenRM0AEklc.jpg","background_path":"/f5uNbUC76oowt5mt5J9QlqrIYQ6.jpg","popularity":91.912012,"score":7.1},{"title":"Doctor Who","year":2005,"type":"show","id":57243,"summary":"The Doctor looks and seems human. He's handsome, witty, and could be mistaken for just another man in the street. But he is a Time Lord: a 900 year old alien with 2 hearts, part of a gifted civilization who mastered time travel. The Doctor saves planets for a living – more of a hobby actually, and he's very, very good at it. He's saved us from alien menaces and evil from before time began – but just who is he?","poster_path":"/cFcZYgPRFZdBkA7EsxHz5Cb8x5.jpg","background_path":"/tQkigP2fItdzJWvtIhBvHxgs5yE.jpg","popularity":87.893522,"score":7},{"title":"Family Guy","year":1999,"type":"show","id":1434,"summary":"Sick, twisted, politically incorrect and Freakin' Sweet animated series featuring the adventures of the dysfunctional Griffin family. Bumbling Peter and long-suffering Lois have three kids. Stewie (a brilliant but sadistic baby bent on killing his mother and taking over the world), Meg (the oldest, and is the most unpopular girl in town) and Chris (the middle kid, he's not very bright but has a passion for movies). The final member of the family is Brian - a talking dog and much more than a pet, he keeps Stewie in check whilst sipping Martinis and sorting through his own life issues.","poster_path":"/gBGUL1UTUNmdRQT8gA1LUV4yg39.jpg","background_path":"/pH38r4TWTqq7Mcs6XAlwgzNUeJe.jpg","popularity":86.53606,"score":6.7},{"title":"Vikings","year":2013,"type":"show","id":44217,"summary":"Vikings follows the adventures of Ragnar Lothbrok, the greatest hero of his age. The series tells the sagas of Ragnar's band of Viking brothers and his family, as he rises to become King of the Viking tribes. As well as being a fearless warrior, Ragnar embodies the Norse traditions of devotion to the gods. Legend has it that he was a direct descendant of Odin, the god of war and warriors.","poster_path":"/oktTNFM8PzdseiK1X0E0XhB6LvP.jpg","background_path":"/A30ZqEoDbchvE7mCZcSp6TEwB1Q.jpg","popularity":83.461205,"score":7.4},{"title":"Grey's Anatomy","year":2005,"type":"show","id":1416,"summary":"Follows the personal and professional lives of a group of doctors at Seattle’s Grey Sloan Memorial Hospital.","poster_path":"/mgOZSS2FFIGtfVeac1buBw3Cx5w.jpg","background_path":"/y6JABtgWMVYPx84Rvy7tROU5aNH.jpg","popularity":83.185481,"score":6.2},{"title":"NCIS","year":2003,"type":"show","id":4614,"summary":"NCIS is an American police procedural drama television series, revolving around a fictional team of special agents from the Naval Criminal Investigative Service, which conducts criminal investigations involving the U.S. Navy and Marine Corps.","poster_path":"/1ubAPydzsb9VzhqeUGGDA7DZCUy.jpg","background_path":"/nymeWHYQ1JaWP2wyNW5a5WHiDCd.jpg","popularity":83.084046,"score":6.6},{"title":"Breaking Bad","year":2008,"type":"show","id":1396,"summary":"Breaking Bad is an American crime drama television series created and produced by Vince Gilligan. Set and produced in Albuquerque, New Mexico, Breaking Bad is the story of Walter White, a struggling high school chemistry teacher who is diagnosed with inoperable lung cancer at the beginning of the series. He turns to a life of crime, producing and selling methamphetamine, in order to secure his family's financial future before he dies, teaming with his former student, Jesse Pinkman. Heavily serialized, the series is known for positioning its characters in seemingly inextricable corners and has been labeled a contemporary western by its creator.","poster_path":"/1yeVJox3rjo2jBKrrihIMj7uoS9.jpg","background_path":"/bzoZjhbpriBT2N5kwgK0weUfVOX.jpg","popularity":82.291087,"score":8.3},{"title":"The Missing","year":2014,"type":"show","id":61555,"summary":"A gripping anthological relationship thriller series exploring the emotional fallout of a child's abduction not only on the family but on the wider community, told over two time frames.","poster_path":"/w1FDeOGoFS1qsSRHlj2Jzp2P0e1.jpg","background_path":"/2hF2RnjVwHvxfhH2lkB9H9FdQHb.jpg","popularity":80.13648,"score":7.3},{"title":"Supergirl","year":2015,"type":"show","id":62688,"summary":"Twenty-four-year-old Kara Zor-El, who was taken in by the Danvers family when she was 13 after being sent away from Krypton, must learn to embrace her powers after previously hiding them. The Danvers teach her to be careful with her powers, until she has to reveal them during an unexpected disaster, setting her on her journey of heroism.","poster_path":"/ufoGrTRbItHvqk42yNHcyoE0afM.jpg","background_path":"/lyA5Bw5paTzsVFGYHx3EbZNR9mK.jpg","popularity":74.295533,"score":5.6},{"title":"Game of Thrones","year":2011,"type":"show","id":1399,"summary":"Seven noble families fight for control of the mythical land of Westeros. Friction between the houses leads to full-scale war. All while a very ancient evil awakens in the farthest north. Amidst the war, a neglected military order of misfits, the Night's Watch, is all that stands between the realms of men and icy horrors beyond.","poster_path":"/gwPSoYUHAKmdyVywgLpKKA4BjRr.jpg","background_path":"/gX8SYlnL9ZznfZwEH4KJUePBFUM.jpg","popularity":72.329765,"score":8.1},{"title":"Friends","year":1994,"type":"show","id":1668,"summary":"Friends is an American sitcom revolving around a group of friends in the New York City borough of Manhattan. Episodes typically depict the friends' comedic and romantic adventures and career issues, such as Joey auditioning for roles or Rachel seeking jobs in the fashion industry. The six characters each have many dates and serious relationships, such as Monica with Richard Burke and Ross with Emily Waltham. Other frequently recurring characters include Ross and Monica's parents in Long Island, Ross's ex-wife and their son, Central Perk barista Gunther, Chandler's ex-girlfriend Janice, and Phoebe's twin sister Ursula.","poster_path":"/7buCWBTpiPrCF5Lt023dSC60rgS.jpg","background_path":"/efiX8iir6GEBWCD0uCFIi5NAyYA.jpg","popularity":71.73907,"score":7.8}],"page":1,"total_pages":1002,"total_results":20030} \ No newline at end of file +{ + "page": 1, + "results": [ + { + "background_path": "/nGsNruW3W27V6r4gkyc3iiEGsKR.jpg", + "id": 1418, + "popularity": 265.003846, + "poster_path": "/ooBGRQBdbGzBxAVfExiO8r7kloA.jpg", + "score": 6.8, + "summary": "The Big Bang Theory is centered on five characters living in Pasadena, California: roommates Leonard Hofstadter and Sheldon Cooper; Penny, a waitress and aspiring actress who lives across the hall; and Leonard and Sheldon's equally geeky and socially awkward friends and co-workers, mechanical engineer Howard Wolowitz and astrophysicist Raj Koothrappali. The geekiness and intellect of the four guys is contrasted for comic effect with Penny's social skills and common sense.", + "title": "The Big Bang Theory", + "type": "show", + "year": 2007 + }, + { + "background_path": "/xVzvD5BPAU4HpleFSo8QOdHkndo.jpg", + "id": 1402, + "popularity": 259.746702, + "poster_path": "/yn7psGTZsHumHOkLUmYpyrIcA2G.jpg", + "score": 7.4, + "summary": "Sheriff's deputy Rick Grimes awakens from a coma to find a post-apocalyptic world dominated by flesh-eating zombies. He sets out to find his family and encounters many other survivors along the way.", + "title": "The Walking Dead", + "type": "show", + "year": 2010 + }, + { + "background_path": "/a906PH7CDmSOdS7kmnAgdWk5mhv.jpg", + "id": 67744, + "popularity": 133.480285, + "poster_path": "/zVuc3Sfs6gyJm6M6Iq52jqdavw4.jpg", + "score": 7.5, + "summary": "An agent in the FBI's Elite Serial Crime Unit develops profiling techniques as he pursues notorious serial killers and rapists.", + "title": "Mindhunter", + "type": "show", + "year": 2017 + }, + { + "background_path": "/pH38r4TWTqq7Mcs6XAlwgzNUeJe.jpg", + "id": 1434, + "popularity": 115.294602, + "poster_path": "/gBGUL1UTUNmdRQT8gA1LUV4yg39.jpg", + "score": 6.6, + "summary": "Sick, twisted, politically incorrect and Freakin' Sweet animated series featuring the adventures of the dysfunctional Griffin family. Bumbling Peter and long-suffering Lois have three kids. Stewie (a brilliant but sadistic baby bent on killing his mother and taking over the world), Meg (the oldest, and is the most unpopular girl in town) and Chris (the middle kid, he's not very bright but has a passion for movies). The final member of the family is Brian - a talking dog and much more than a pet, he keeps Stewie in check whilst sipping Martinis and sorting through his own life issues.", + "title": "Family Guy", + "type": "show", + "year": 1999 + }, + { + "background_path": "/qtr5i6hOm6oVzTYl3jOQAYP3oc7.jpg", + "id": 1403, + "popularity": 111.281986, + "poster_path": "/xjm6uVktPuKXNILwjLXwVG5d5BU.jpg", + "score": 6.7, + "summary": "Agent Phil Coulson of S.H.I.E.L.D. (Strategic Homeland Intervention, Enforcement and Logistics Division) puts together a team of agents to investigate the new, the strange and the unknown around the globe, protecting the ordinary from the extraordinary.", + "title": "Marvel's Agents of S.H.I.E.L.D.", + "type": "show", + "year": 2013 + }, + { + "background_path": "/mmxxEpTqVdwBlu5Pii7tbedBkPC.jpg", + "id": 60735, + "popularity": 109.249893, + "poster_path": "/lUFK7ElGCk9kVEryDJHICeNdmd1.jpg", + "score": 6.7, + "summary": "After a particle accelerator causes a freak storm, CSI Investigator Barry Allen is struck by lightning and falls into a coma. Months later he awakens with the power of super speed, granting him the ability to move through Central City like an unseen guardian angel. Though initially excited by his newfound powers, Barry is shocked to discover he is not the only \"meta-human\" who was created in the wake of the accelerator explosion -- and not everyone is using their new powers for good. Barry partners with S.T.A.R. Labs and dedicates his life to protect the innocent. For now, only a few close friends and associates know that Barry is literally the fastest man alive, but it won't be long before the world learns what Barry Allen has become...The Flash.", + "title": "The Flash", + "type": "show", + "year": 2014 + }, + { + "background_path": "/f5uNbUC76oowt5mt5J9QlqrIYQ6.jpg", + "id": 456, + "popularity": 104.645298, + "poster_path": "/yTZQkSsxUFJZJe67IenRM0AEklc.jpg", + "score": 7.1, + "summary": "Set in Springfield, the average American town, the show focuses on the antics and everyday adventures of the Simpson family; Homer, Marge, Bart, Lisa and Maggie, as well as a virtual cast of thousands. Since the beginning, the series has been a pop culture icon, attracting hundreds of celebrities to guest star. The show has also made name for itself in its fearless satirical take on politics, media and American life in general.", + "title": "The Simpsons", + "type": "show", + "year": 1989 + }, + { + "background_path": "/2hF2RnjVwHvxfhH2lkB9H9FdQHb.jpg", + "id": 61555, + "popularity": 94.412332, + "poster_path": "/w1FDeOGoFS1qsSRHlj2Jzp2P0e1.jpg", + "score": 7.3, + "summary": "A gripping anthological relationship thriller series exploring the emotional fallout of a child's abduction not only on the family but on the wider community, told over two time frames.", + "title": "The Missing", + "type": "show", + "year": 2014 + }, + { + "background_path": "/dKxkwAJfGuznW8Hu0mhaDJtna0n.jpg", + "id": 1412, + "popularity": 85.601456, + "poster_path": "/mo0FP1GxOFZT4UDde7RFDz5APXF.jpg", + "score": 6, + "summary": "Spoiled billionaire playboy Oliver Queen is missing and presumed dead when his yacht is lost at sea. He returns five years later a changed man, determined to clean up the city as a hooded vigilante armed with a bow.", + "title": "Arrow", + "type": "show", + "year": 2012 + }, + { + "background_path": "/o9OKe3M06QMLOzTl3l6GStYtnE9.jpg", + "id": 1622, + "popularity": 85.36772, + "poster_path": "/pui1V389cQft0BVFu9pbsYLEW1Q.jpg", + "score": 7.2, + "summary": "When they were boys, Sam and Dean Winchester lost their mother to a mysterious and demonic supernatural force. Subsequently, their father raised them to be soldiers. He taught them about the paranormal evil that lives in the dark corners and on the back roads of America ... and he taught them how to kill it. Now, the Winchester brothers crisscross the country in their '67 Chevy Impala, battling every kind of supernatural threat they encounter along the way. ", + "title": "Supernatural", + "type": "show", + "year": 2005 + }, + { + "background_path": "/snxFgPvHMcpW5f8Q3wu6uRRycww.jpg", + "id": 1421, + "popularity": 81.016473, + "poster_path": "/gLAcu4VPCAb90oJvJ4nUJc5ZBQi.jpg", + "score": 7.3, + "summary": "The Pritchett-Dunphy-Tucker clan is a wonderfully large and blended family. They give us an honest and often hilarious look into the sometimes warm, sometimes twisted, embrace of the modern family.", + "title": "Modern Family", + "type": "show", + "year": 2009 + }, + { + "background_path": "/hTxfw4af6EizpLM7tHKtoSlbdnu.jpg", + "id": 1407, + "popularity": 78.331466, + "poster_path": "/lT8o38ubu9uzcjZbkDtwsVizDeQ.jpg", + "score": 7.3, + "summary": "CIA officer Carrie Mathison is tops in her field despite being bipolar, which makes her volatile and unpredictable. With the help of her long-time mentor Saul Berenson, Carrie fearlessly risks everything, including her personal well-being and even sanity, at every turn.", + "title": "Homeland", + "type": "show", + "year": 2011 + }, + { + "background_path": "/mKBP1OCgCG0jw8DwVYlnYqVILtc.jpg", + "id": 60708, + "popularity": 78.270408, + "poster_path": "/5tSHzkJ1HBnyGdcpr6wSyw7jYnJ.jpg", + "score": 6.9, + "summary": "Before there was Batman, there was GOTHAM. \n\nEveryone knows the name Commissioner Gordon. He is one of the crime world's greatest foes, a man whose reputation is synonymous with law and order. But what is known of Gordon's story and his rise from rookie detective to Police Commissioner? What did it take to navigate the multiple layers of corruption that secretly ruled Gotham City, the spawning ground of the world's most iconic villains? And what circumstances created them – the larger-than-life personas who would become Catwoman, The Penguin, The Riddler, Two-Face and The Joker? ", + "title": "Gotham", + "type": "show", + "year": 2014 + }, + { + "background_path": "/kOvt2BOOwSAQCT8yo3pM3X2GXjh.jpg", + "id": 2734, + "popularity": 77.581038, + "poster_path": "/yzMQBlirydvKp4Zgr5FbXlsrRmw.jpg", + "score": 6.2, + "summary": "In the criminal justice system, sexually-based offenses are considered especially heinous. In New York City, the dedicated detectives who investigate these vicious felonies are members of an elite squad known as the Special Victims Unit. These are their stories.", + "title": "Law & Order: Special Victims Unit", + "type": "show", + "year": 1999 + }, + { + "background_path": "/y6JABtgWMVYPx84Rvy7tROU5aNH.jpg", + "id": 1416, + "popularity": 77.265382, + "poster_path": "/mgOZSS2FFIGtfVeac1buBw3Cx5w.jpg", + "score": 6.2, + "summary": "Follows the personal and professional lives of a group of doctors at Seattle’s Grey Sloan Memorial Hospital.", + "title": "Grey's Anatomy", + "type": "show", + "year": 2005 + }, + { + "background_path": "/hQOrVu62yJkMkyKDKdzMt6MzdIQ.jpg", + "id": 72837, + "popularity": 75.714532, + "poster_path": "/pyruRb239sh6DUtj8FtjtOZG1d4.jpg", + "score": 2, + "summary": "Secret Story takes more or less the basic principles of Big Brother, a reality show created in 1997 by the Dutchman John de Mol. The game contestants are cut off from the rest of the world during ten to fifteen weeks in a house called “house of secrets”, where every room is fitted with video cameras, except the restroom. They have to keep a secret while trying to discover the other contestants’ one.", + "title": "Secret Story - Casa dos Segredos", + "type": "show", + "year": 2010 + }, + { + "background_path": "/efiX8iir6GEBWCD0uCFIi5NAyYA.jpg", + "id": 1668, + "popularity": 74.555045, + "poster_path": "/7buCWBTpiPrCF5Lt023dSC60rgS.jpg", + "score": 7.8, + "summary": "Friends is an American sitcom revolving around a group of friends in the New York City borough of Manhattan. Episodes typically depict the friends' comedic and romantic adventures and career issues, such as Joey auditioning for roles or Rachel seeking jobs in the fashion industry. The six characters each have many dates and serious relationships, such as Monica with Richard Burke and Ross with Emily Waltham. Other frequently recurring characters include Ross and Monica's parents in Long Island, Ross's ex-wife and their son, Central Perk barista Gunther, Chandler's ex-girlfriend Janice, and Phoebe's twin sister Ursula.", + "title": "Friends", + "type": "show", + "year": 1994 + }, + { + "background_path": "/gX8SYlnL9ZznfZwEH4KJUePBFUM.jpg", + "id": 1399, + "popularity": 73.757691, + "poster_path": "/gwPSoYUHAKmdyVywgLpKKA4BjRr.jpg", + "score": 8.1, + "summary": "Seven noble families fight for control of the mythical land of Westeros. Friction between the houses leads to full-scale war. All while a very ancient evil awakens in the farthest north. Amidst the war, a neglected military order of misfits, the Night's Watch, is all that stands between the realms of men and icy horrors beyond.", + "title": "Game of Thrones", + "type": "show", + "year": 2011 + }, + { + "background_path": "/uqu5SuPIr0VQPqXF7CuGY3j2431.jpg", + "id": 2046, + "popularity": 71.597403, + "poster_path": "/bMj6iM7TBcceG44vpireA2Axeab.jpg", + "score": 6.2, + "summary": "Sydney Bristow, an agent who has been tricked to believe she is working for the U.S. government, is actually working for a criminal organization named the Alliance of Twelve. Upon learning this, Sydney becomes a double agent for the real CIA.", + "title": "Alias", + "type": "show", + "year": 2001 + }, + { + "background_path": "/xHCfWGlxwbtMeeOnTvxUCZRGnkk.jpg", + "id": 62127, + "popularity": 71.366535, + "poster_path": "/nv4nLXbDhcISPP8C1mgaxKU50KO.jpg", + "score": 6.1, + "summary": "Danny Rand resurfaces 15 years after being presumed dead. Now, with the power of the Iron Fist, he seeks to reclaim his past and fulfill his destiny.", + "title": "Marvel's Iron Fist", + "type": "show", + "year": 2017 + } + ], + "total_pages": 1002, + "total_results": 20037 +} \ No newline at end of file From e914e4ab457a8154b6bf595e673efcfab47c84f3 Mon Sep 17 00:00:00 2001 From: Kevin Date: Wed, 21 Mar 2018 23:44:59 +0100 Subject: [PATCH 8/8] Added ORDER BY date that was missing in sql stmt --- seasoned_api/src/plex/requestRepository.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seasoned_api/src/plex/requestRepository.js b/seasoned_api/src/plex/requestRepository.js index db37207..94e368c 100644 --- a/seasoned_api/src/plex/requestRepository.js +++ b/seasoned_api/src/plex/requestRepository.js @@ -19,7 +19,7 @@ class RequestRepository { insertRequest: `INSERT INTO requests(id,title,year,poster_path,background_path,requested_by,ip,user_agent,type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, fetchRequestedItems: 'SELECT * FROM requests ORDER BY date DESC LIMIT 25 OFFSET ?*25-25', - fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ? DESC LIMIT 25 OFFSET ?*25-25', + fetchRequestedItemsByStatus: 'SELECT * FROM requests WHERE status IS ? AND type LIKE ? ORDER BY date DESC LIMIT 25 OFFSET ?*25-25', updateRequestedById: 'UPDATE requests SET status = ? WHERE id is ? AND type is ?', checkIfIdRequested: 'SELECT * FROM requests WHERE id IS ? AND type IS ?', userRequests: 'SELECT * FROM requests WHERE requested_by IS ?'