<commit_before>import { postgresConnection as cn } from '../../config/helpers.js';
const pgp = require('pg-promise')();
const db = pgp(cn);<commit_msg>Add getAllLikedRecipes method, to get all liked recipes for a single user<commit_after>import { postgresConnection as cn } from '../../config/helpers.js';
const pgp = require('pg-promise')();
const db = pgp(cn);


module.exports = {


  getAllLikedRecipes: (request, response, next) => {
    const newQueryObj = {
      name: 'get-my-favorite-recipes',
      text: `SELECT
              *
            FROM
              recipes r INNER JOIN likes_recipes_users lru
            ON
              lru.recipe_id = r.id INNER JOIN users u
            ON
              lru.user_id = u.id
            WHERE
              u.id = $1;`,
      values: [
        request.params.user,
      ],
    }

    db.query(newQueryObj)
      .then((data) => {
        response.status(200);
        response.json(data);
        next();
      })
      .catch((error) => {
        console.log(error);
        next();
      });
  }
};
{'fraction_non_alphanumeric': 0.1369216241737488, 'fraction_numerical': 0.003777148253068933, 'mean_word_length': 1.8342245989304813, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5379762', 'n_tokens_mistral': 336, 'n_tokens_neox': 330, 'n_words': 75}