From d12f9d9872361b5176d4af2bc2910637c2c70503 Mon Sep 17 00:00:00 2001 From: kyrea Date: Mon, 11 Mar 2024 20:15:15 +0530 Subject: [PATCH 1/6] Fixed waifu query using anime --- src/controllers/v4/images/waifu.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/controllers/v4/images/waifu.js b/src/controllers/v4/images/waifu.js index b62014c..785cc49 100644 --- a/src/controllers/v4/images/waifu.js +++ b/src/controllers/v4/images/waifu.js @@ -44,7 +44,14 @@ const getWaifu = async (req, res, next) => { if (anime) { const sanitizedAnime = _.escapeRegExp(anime.trim()); - filter['media.nodes[0].title.userPreferred'] = { $regex: new RegExp(sanitizedAnime, 'i') }; // Case-insensitive regex match for anime name + filter['media.nodes'] = { + $elemMatch: { + $or: [ + { 'title.userPreferred': { $regex: new RegExp(sanitizedAnime, 'i') } }, + { synonyms: { $regex: new RegExp(sanitizedAnime, 'i') } }, + ], + }, + }; } /** From a9fb0f01c44fb9501378a4e7ee89bc23b8711afd Mon Sep 17 00:00:00 2001 From: kyrea Date: Mon, 20 May 2024 17:05:39 +0530 Subject: [PATCH 2/6] Fixed "uwuify is not a function" --- src/controllers/v4/textUtilities/uwuify.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/v4/textUtilities/uwuify.js b/src/controllers/v4/textUtilities/uwuify.js index 3b79d7a..3ead9e2 100644 --- a/src/controllers/v4/textUtilities/uwuify.js +++ b/src/controllers/v4/textUtilities/uwuify.js @@ -1,6 +1,7 @@ import createError from 'http-errors'; import uwuify from 'owoify-js'; import Stats from '../../../models/schemas/Stat.js'; +const generateText = uwuify.default; /** * Route handler to get UwUified text. @@ -20,7 +21,7 @@ const getUwuifyText = async (req, res, next) => { // UwUify the text and send the response res.status(200).json({ - text: uwuify(text), + text: generateText(text, 'uwu'), }); // Increment the UwUify counter in the stats From badb0905ebf4ed9991264819ab747caace995a8b Mon Sep 17 00:00:00 2001 From: kyrea Date: Mon, 20 May 2024 17:05:57 +0530 Subject: [PATCH 3/6] Fixed "owoify is not a function" --- src/controllers/v4/textUtilities/owoify.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/v4/textUtilities/owoify.js b/src/controllers/v4/textUtilities/owoify.js index 15213b4..639096f 100644 --- a/src/controllers/v4/textUtilities/owoify.js +++ b/src/controllers/v4/textUtilities/owoify.js @@ -1,6 +1,7 @@ import createError from 'http-errors'; import owoify from 'owoify-js'; import Stats from '../../../models/schemas/Stat.js'; +const generateText = owoify.default; /** * Gets the Owofied version of the provided text and updates system statistics. @@ -38,7 +39,7 @@ const getOwoifyText = async (req, res, next) => { * @property {String} text - The Owofied version of the provided text. */ res.status(200).json({ - text: owoify(text), + text: generateText(text), }); /** From dbd18cf42243de3c9b80383f30420f17d7dcda64 Mon Sep 17 00:00:00 2001 From: kyrea Date: Mon, 20 May 2024 17:06:10 +0530 Subject: [PATCH 4/6] Fixed "uvuify is not a function" --- src/controllers/v4/textUtilities/uvuify.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/v4/textUtilities/uvuify.js b/src/controllers/v4/textUtilities/uvuify.js index 1bfe5a9..0b5121e 100644 --- a/src/controllers/v4/textUtilities/uvuify.js +++ b/src/controllers/v4/textUtilities/uvuify.js @@ -1,6 +1,7 @@ import createError from 'http-errors'; import uvuify from 'owoify-js'; import Stats from '../../../models/schemas/Stat.js'; +const generateText = uvuify.default; /** * Route handler to get UvUified text. @@ -20,7 +21,7 @@ const getUvuifyText = async (req, res, next) => { // UvUify the text and send the response res.status(200).json({ - text: uvuify(text), + text: generateText(text, 'uvu'), }); // Increment the UvUify counter in the stats From 6e4a36c046ce018d9b401eae2f0bf4e62a6bf5fe Mon Sep 17 00:00:00 2001 From: kyrea Date: Mon, 20 May 2024 17:15:01 +0530 Subject: [PATCH 5/6] Added feature to query quotes using anime name --- src/controllers/v4/textUtilities/quote.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/controllers/v4/textUtilities/quote.js b/src/controllers/v4/textUtilities/quote.js index a675a96..ba21b8f 100644 --- a/src/controllers/v4/textUtilities/quote.js +++ b/src/controllers/v4/textUtilities/quote.js @@ -15,14 +15,23 @@ const getQuote = async (req, res, next) => { * Extract character parameter from the query * @type {string} */ - const { character } = req.query; + const { character, anime } = req.query; /** * Create a filter object based on the optional character parameter * @type {Object} */ - const filter = character ? { author: character } : {}; - + /** + * Create a filter object based on the optional character and anime parameters + * @type {Object} + */ + const filter = {}; + if (character) { + filter.author = { $regex: character, $options: 'i' }; + } + if (anime) { + filter.anime = { $regex: anime, $options: 'i' }; + } /** * Aggregate to match the filter, select a random quote, and project excluding version field * @type {Array} From 7d371c4849073834c8b747257f5b71bb50fd3520 Mon Sep 17 00:00:00 2001 From: kyrea Date: Mon, 20 May 2024 17:24:53 +0530 Subject: [PATCH 6/6] Bumped version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4ab6ad4..6e6aaf6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "waifu.it", - "version": "4.5.15", + "version": "4.6.0", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/package.json b/package.json index e42b0c8..5f2fa35 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "waifu.it", - "version": "4.5.15", + "version": "4.6.0", "description": "Random API Serving Anime stuff", "author": "Aeryk", "private": true,