diff --git a/seasoned_api/src/tmdb/tmdb.js b/seasoned_api/src/tmdb/tmdb.js index b55dc64..2486f1a 100644 --- a/seasoned_api/src/tmdb/tmdb.js +++ b/seasoned_api/src/tmdb/tmdb.js @@ -144,9 +144,9 @@ class TMDB { .then(person => Person.convertFromTmdbResponse(person)) } - multiSearch(search_query, page=1) { - const query = { query: search_query, page: page }; - const cacheKey = `tmdb/${this.cacheTags.multiSearch}:${page}:${search_query}`; + multiSearch(search_query, page=1, adult=true) { + const query = { query: search_query, page: page, include_adult: adult }; + const cacheKey = `tmdb/${this.cacheTags.multiSearch}:${page}:${search_query}:${adult}`; return this.getFromCacheOrFetchFromTmdb(cacheKey, 'searchMulti', query) .then(response => this.cache.set(cacheKey, response, this.defaultTTL)) @@ -159,9 +159,9 @@ class TMDB { * @param {Number} page representing pagination of results * @returns {Promise} dict with query results, current page and total_pages */ - movieSearch(query, page=1) { - const tmdbquery = { query: query, page: page }; - const cacheKey = `tmdb/${this.cacheTags.movieSearch}:${page}:${query}`; + movieSearch(query, page=1, adult=true) { + const tmdbquery = { query: query, page: page, adult: adult }; + const cacheKey = `tmdb/${this.cacheTags.movieSearch}:${page}:${query}:${adult}`; return this.getFromCacheOrFetchFromTmdb(cacheKey, 'searchMovie', query) .then(response => this.cache.set(cacheKey, response, this.defaultTTL)) @@ -192,7 +192,7 @@ class TMDB { personSearch(query, page=1) { const tmdbquery = { query: query, page: page, include_adult: true }; - const cacheKey = `tmdb/${this.cacheTags.personSearch}:${page}:${query}`; + const cacheKey = `tmdb/${this.cacheTags.personSearch}:${page}:${query}:${include_adult}`; return this.getFromCacheOrFetchFromTmdb(cacheKey, 'searchPerson', query) .then(response => this.cache.set(cacheKey, response, this.defaultTTL)) diff --git a/seasoned_api/src/webserver/controllers/search/multiSearch.js b/seasoned_api/src/webserver/controllers/search/multiSearch.js index a9cc40a..e71b388 100644 --- a/seasoned_api/src/webserver/controllers/search/multiSearch.js +++ b/seasoned_api/src/webserver/controllers/search/multiSearch.js @@ -19,13 +19,13 @@ function checkAndCreateJsonResponse(result) { */ function multiSearchController(req, res) { const user = req.loggedInUser; - const { query, page } = req.query; + const { query, page, adult } = req.query; if (user) { searchHistory.create(user.username, query) } - return tmdb.multiSearch(query, page) + return tmdb.multiSearch(query, page, adult) .then(multiSearchResults => res.send(multiSearchResults)) .catch(error => { const { status, message } = error;