diff options
author | 2021-12-02 23:57:13 +0100 | |
---|---|---|
committer | 2021-12-03 04:27:13 +0530 | |
commit | f64f1b3bd9bec4036748b98ff8ac0f0431749f30 (patch) | |
tree | 33691b4b02a546a7a1665ca29b18e3baa135c9ef /src/internal-server/app/Controllers/Http/RecipeController.js | |
parent | 5.6.4-nightly.22 [skip ci] (diff) | |
download | ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.tar.gz ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.tar.zst ferdium-app-f64f1b3bd9bec4036748b98ff8ac0f0431749f30.zip |
chore: upgrade commitlint and eslint-plugin-unicorn to latest (#2295)
- upgrade commitlint and eslint-plugin-unicorn dependencies
- update prepare-code script to run lint:fix instead of lint
- fix unicorn/no-await-expression-member lint issues
- various whitespace formatting fixes due to lint:fix
Diffstat (limited to 'src/internal-server/app/Controllers/Http/RecipeController.js')
-rw-r--r-- | src/internal-server/app/Controllers/Http/RecipeController.js | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/internal-server/app/Controllers/Http/RecipeController.js b/src/internal-server/app/Controllers/Http/RecipeController.js index 1b0ac7035..7e35e6831 100644 --- a/src/internal-server/app/Controllers/Http/RecipeController.js +++ b/src/internal-server/app/Controllers/Http/RecipeController.js | |||
@@ -13,8 +13,10 @@ const RECIPES_URL = `${LIVE_FERDI_API}/${API_VERSION}/recipes`; | |||
13 | class RecipeController { | 13 | class RecipeController { |
14 | // List official and custom recipes | 14 | // List official and custom recipes |
15 | async list({ response }) { | 15 | async list({ response }) { |
16 | const officialRecipes = JSON.parse(await (await fetch(RECIPES_URL)).text()); | 16 | const recipesUrlFetch = await fetch(RECIPES_URL); |
17 | const customRecipesArray = (await Recipe.all()).rows; | 17 | const officialRecipes = JSON.parse(await recipesUrlFetch).text(); |
18 | const allRecipes = await Recipe.all(); | ||
19 | const customRecipesArray = allRecipes.rows; | ||
18 | const customRecipes = customRecipesArray.map(recipe => ({ | 20 | const customRecipes = customRecipesArray.map(recipe => ({ |
19 | id: recipe.recipeId, | 21 | id: recipe.recipeId, |
20 | name: recipe.name, | 22 | name: recipe.name, |
@@ -46,7 +48,8 @@ class RecipeController { | |||
46 | let results; | 48 | let results; |
47 | 49 | ||
48 | if (needle === 'ferdi:custom') { | 50 | if (needle === 'ferdi:custom') { |
49 | const dbResults = (await Recipe.all()).toJSON(); | 51 | const allRecipes = await Recipe.all(); |
52 | const dbResults = allRecipes.toJSON(); | ||
50 | results = dbResults.map(recipe => ({ | 53 | results = dbResults.map(recipe => ({ |
51 | id: recipe.recipeId, | 54 | id: recipe.recipeId, |
52 | name: recipe.name, | 55 | name: recipe.name, |
@@ -56,20 +59,18 @@ class RecipeController { | |||
56 | let remoteResults = []; | 59 | let remoteResults = []; |
57 | // eslint-disable-next-line eqeqeq | 60 | // eslint-disable-next-line eqeqeq |
58 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { | 61 | if (Env.get('CONNECT_WITH_FRANZ') == 'true') { |
59 | remoteResults = JSON.parse( | 62 | const recipesUrlFetch = await fetch( |
60 | await ( | 63 | `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, |
61 | await fetch( | ||
62 | `${RECIPES_URL}/search?needle=${encodeURIComponent(needle)}`, | ||
63 | ) | ||
64 | ).text(), | ||
65 | ); | 64 | ); |
65 | remoteResults = JSON.parse(await recipesUrlFetch.text()); | ||
66 | } | 66 | } |
67 | 67 | ||
68 | debug('remoteResults:', remoteResults); | 68 | debug('remoteResults:', remoteResults); |
69 | 69 | ||
70 | const localResultsArray = ( | 70 | const recipeQuery = await Recipe.query() |
71 | await Recipe.query().where('name', 'LIKE', `%${needle}%`).fetch() | 71 | .where('name', 'LIKE', `%${needle}%`) |
72 | ).toJSON(); | 72 | .fetch(); |
73 | const localResultsArray = recipeQuery.toJSON(); | ||
73 | const localResults = localResultsArray.map(recipe => ({ | 74 | const localResults = localResultsArray.map(recipe => ({ |
74 | id: recipe.recipeId, | 75 | id: recipe.recipeId, |
75 | name: recipe.name, | 76 | name: recipe.name, |