From 4bef83679bfa5e3599b82f81499704e1832db018 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 17:12:07 -0500 Subject: [PATCH 01/20] Add GitHub Actions workflow for Super Linter --- .github/workflows/super-linter.yml | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/super-linter.yml diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml new file mode 100644 index 0000000..a5c404f --- /dev/null +++ b/.github/workflows/super-linter.yml @@ -0,0 +1,34 @@ +--- +name: Lint + +on: + push: null + pull_request: null + +permissions: {} + +jobs: + build: + name: Lint + runs-on: ubuntu-latest + + permissions: + contents: read + packages: read + # To report GitHub Actions status checks + statuses: write + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # super-linter needs the full git history to get the + # list of files that changed across commits + fetch-depth: 0 + + - name: Super-linter + uses: super-linter/super-linter@v7.2.1 + env: + # To report GitHub Actions status checks + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + VALIDATE_ALL_CODEBASE: true From e093b44774a9941cfeb55a3cae0759df31decb39 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 17:17:04 -0500 Subject: [PATCH 02/20] Add SQLFluff configuration and update Super Linter workflow --- .github/workflows/super-linter.yml | 2 ++ .sqlfluff | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 .sqlfluff diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index a5c404f..f7ca604 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -32,3 +32,5 @@ jobs: # To report GitHub Actions status checks GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} VALIDATE_ALL_CODEBASE: true + VALIDATE_JSON_PRETTIER: false + SQLFLUFF_CONFIG_FILE: .sqlfluff diff --git a/.sqlfluff b/.sqlfluff new file mode 100644 index 0000000..0a33ea9 --- /dev/null +++ b/.sqlfluff @@ -0,0 +1,5 @@ +[sqlfluff] +dialect = mariadb +max_line_length = 100 +exlude_rules = PRS +ignore = parsing From f3737d78992dfa94137219ddaf19e6fa61f1166c Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 17:36:24 -0500 Subject: [PATCH 03/20] Refactor pagination logic in recipe procedures for clarity and consistency --- procedures/get/recipe.sql | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/procedures/get/recipe.sql b/procedures/get/recipe.sql index a7d8ab8..3e9d41a 100644 --- a/procedures/get/recipe.sql +++ b/procedures/get/recipe.sql @@ -42,7 +42,9 @@ CREATE OR REPLACE PROCEDURE get_all_recipes_paginated( ) BEGIN DECLARE v_max_limit INT DEFAULT 30; - DECLARE v_offset INT DEFAULT (p_offset - 1) * p_limit; + DECLARE v_offset INT; + + SET v_offset = (p_offset - 1) * p_limit; SET p_limit = LEAST(p_limit, v_max_limit); SELECT @@ -71,7 +73,9 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_author_paginated( ) BEGIN DECLARE v_max_limit INT DEFAULT 30; - DECLARE v_offset INT DEFAULT (p_offset - 1) * p_limit; + DECLARE v_offset INT; + + SET v_offset = (p_offset - 1) * p_limit; SET p_limit = LEAST(p_limit, v_max_limit); SELECT @@ -98,7 +102,9 @@ CREATE OR REPLACE PROCEDURE get_top_rated_recipes_paginated( ) BEGIN DECLARE v_max_limit INT DEFAULT 30; - DECLARE v_offset INT DEFAULT (p_offset - 1) * p_limit; + DECLARE v_offset INT; + + SET v_offset = (p_offset - 1) * p_limit; SET p_limit = LEAST(p_limit, v_max_limit); SELECT @@ -110,7 +116,8 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status, - AVG(rr.rating) AS average_rating, rt.title + AVG(rr.rating) AS average_rating, + rt.title FROM recipe r INNER JOIN recipe_rating rr ON r.recipe_id = rr.recipe_id INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id @@ -130,7 +137,9 @@ CREATE OR REPLACE PROCEDURE get_recipes_liked_by_person_paginated( ) BEGIN DECLARE v_max_limit INT DEFAULT 30; - DECLARE v_offset INT DEFAULT (p_offset - 1) * p_limit; + DECLARE v_offset INT; + + SET v_offset = (p_offset - 1) * p_limit; SET p_limit = LEAST(p_limit, v_max_limit); SELECT @@ -142,11 +151,11 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status - FROM - recipe r + FROM recipe r INNER JOIN recipe_engagement re ON r.recipe_id = re.recipe_id INNER JOIN person p ON r.author_id = p.person_id - WHERE re.person_id = p_person_id AND re.engagement_type = 'like' + WHERE re.person_id = p_person_id + AND re.engagement_type = 'like' LIMIT p_limit OFFSET v_offset; END // @@ -158,7 +167,9 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_category_paginated( ) BEGIN DECLARE v_max_limit INT DEFAULT 30; - DECLARE v_offset INT DEFAULT (p_offset - 1) * p_limit; + DECLARE v_offset INT; + + SET v_offset = (p_offset - 1) * p_limit; SET p_limit = LEAST(p_limit, v_max_limit); SELECT @@ -189,7 +200,9 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_tags_paginated( ) BEGIN DECLARE v_max_limit INT DEFAULT 30; - DECLARE v_offset INT DEFAULT (p_offset - 1) * p_limit; + DECLARE v_offset INT; + + SET v_offset = (p_offset - 1) * p_limit; SET p_limit = LEAST(p_limit, v_max_limit); SELECT @@ -220,11 +233,10 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_name_paginated( ) BEGIN DECLARE v_max_limit INT DEFAULT 30; - DECLARE v_offset INT DEFAULT (p_offset - 1) * p_limit; - DECLARE v_safe_recipe_name VARCHAR(255); + DECLARE v_offset INT; + SET v_offset = (p_offset - 1) * p_limit; SET p_limit = LEAST(p_limit, v_max_limit); - SET v_safe_recipe_name = sanitize_string(p_name); SELECT r.recipe_id, From 08945b9fc12410d050b886bb64717b3699bbfba1 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 17:48:11 -0500 Subject: [PATCH 04/20] Add pagination functions and refactor recipe procedures for improved efficiency --- functions/calculate_offset.sql | 15 +++++++ functions/enforce_row_limit.sql | 14 ++++++ functions/get_recipe_title.sql | 20 +++++++++ procedures/get/recipe.sql | 76 +++++++++++++++++---------------- 4 files changed, 89 insertions(+), 36 deletions(-) create mode 100644 functions/calculate_offset.sql create mode 100644 functions/enforce_row_limit.sql create mode 100644 functions/get_recipe_title.sql diff --git a/functions/calculate_offset.sql b/functions/calculate_offset.sql new file mode 100644 index 0000000..14dff3d --- /dev/null +++ b/functions/calculate_offset.sql @@ -0,0 +1,15 @@ +-- Use the database +USE smartcooking; + +DELIMITER // + +CREATE FUNCTION calculate_offset(p_offset INT, p_limit INT) +RETURNS INT +DETERMINISTIC +BEGIN + DECLARE v_offset INT; + SET v_offset = (p_offset - 1) * LEAST(p_limit, 30); + RETURN v_offset; +END // + +DELIMITER ; diff --git a/functions/enforce_row_limit.sql b/functions/enforce_row_limit.sql new file mode 100644 index 0000000..de3f000 --- /dev/null +++ b/functions/enforce_row_limit.sql @@ -0,0 +1,14 @@ +-- Use the database +USE smartcooking; + +DELIMITER // + +CREATE FUNCTION enforce_row_limit(p_limit INT) +RETURNS INT +DETERMINISTIC +BEGIN + DECLARE v_max_limit INT DEFAULT 30; + RETURN LEAST(p_limit, v_max_limit); +END // + +DELIMITER ; diff --git a/functions/get_recipe_title.sql b/functions/get_recipe_title.sql new file mode 100644 index 0000000..058bfba --- /dev/null +++ b/functions/get_recipe_title.sql @@ -0,0 +1,20 @@ +-- Use the database +USE smartcooking; + +DELIMITER // + +CREATE FUNCTION get_recipe_title(p_recipe_id INT, p_language_iso_code CHAR(2)) +RETURNS VARCHAR(255) +DETERMINISTIC +BEGIN + DECLARE v_title VARCHAR(255); + SELECT rt.title + INTO v_title + FROM recipe_translation rt + INNER JOIN lang l ON rt.language_id = l.language_id + WHERE rt.recipe_id = p_recipe_id + AND l.language_iso_code = p_language_iso_code; + RETURN v_title; +END // + +DELIMITER ; diff --git a/procedures/get/recipe.sql b/procedures/get/recipe.sql index 3e9d41a..31b92dc 100644 --- a/procedures/get/recipe.sql +++ b/procedures/get/recipe.sql @@ -3,12 +3,13 @@ USE smartcooking; DELIMITER // --- This procedure is intended for testing purposes only +-- Testing procedure (unchanged as it does not benefit from the functions) CREATE OR REPLACE PROCEDURE get_all_recipes() BEGIN SELECT * FROM recipe; END // +-- Procedure to fetch recipe details by ID, using the `get_recipe_title` function CREATE OR REPLACE PROCEDURE get_recipe_by_id( IN p_recipe_id INT, IN p_language_iso_code CHAR(2) @@ -22,7 +23,7 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status, - rt.title, + get_recipe_title(p_recipe_id, p_language_iso_code) AS title, rt.details, rt.preparation, rt.nutritional_information, @@ -35,17 +36,18 @@ BEGIN AND l.iso_code = p_language_iso_code; END // +-- Generic template for pagination with limit and offset CREATE OR REPLACE PROCEDURE get_all_recipes_paginated( IN p_limit INT, IN p_offset INT, IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_max_limit INT DEFAULT 30; DECLARE v_offset INT; + DECLARE v_limit INT; - SET v_offset = (p_offset - 1) * p_limit; - SET p_limit = LEAST(p_limit, v_max_limit); + SET v_offset = calculate_offset(p_offset, p_limit); + SET v_limit = enforce_row_limit(p_limit); SELECT r.recipe_id, @@ -56,13 +58,13 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status, - rt.title + get_recipe_title(r.recipe_id, p_language_iso_code) AS title FROM recipe r INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id INNER JOIN lang l ON rt.language_id = l.language_id INNER JOIN person p ON r.author_id = p.person_id WHERE l.iso_code = p_language_iso_code - LIMIT p_limit OFFSET v_offset; + LIMIT v_limit OFFSET v_offset; END // CREATE OR REPLACE PROCEDURE get_recipes_by_author_paginated( @@ -72,11 +74,11 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_author_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_max_limit INT DEFAULT 30; DECLARE v_offset INT; + DECLARE v_limit INT; - SET v_offset = (p_offset - 1) * p_limit; - SET p_limit = LEAST(p_limit, v_max_limit); + SET v_offset = calculate_offset(p_offset, p_limit); + SET v_limit = enforce_row_limit(p_limit); SELECT r.recipe_id, @@ -85,13 +87,13 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status, - rt.title + get_recipe_title(r.recipe_id, p_language_iso_code) AS title FROM recipe r INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id INNER JOIN lang l ON rt.language_id = l.language_id WHERE r.author_id = p_author_id AND l.iso_code = p_language_iso_code - LIMIT p_limit OFFSET v_offset; + LIMIT v_limit OFFSET v_offset; END // CREATE OR REPLACE PROCEDURE get_top_rated_recipes_paginated( @@ -101,11 +103,11 @@ CREATE OR REPLACE PROCEDURE get_top_rated_recipes_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_max_limit INT DEFAULT 30; DECLARE v_offset INT; + DECLARE v_limit INT; - SET v_offset = (p_offset - 1) * p_limit; - SET p_limit = LEAST(p_limit, v_max_limit); + SET v_offset = calculate_offset(p_offset, p_limit); + SET v_limit = enforce_row_limit(p_limit); SELECT r.recipe_id, @@ -117,7 +119,7 @@ BEGIN r.number_of_reviews, r.recipe_status, AVG(rr.rating) AS average_rating, - rt.title + get_recipe_title(r.recipe_id, p_language_iso_code) AS title FROM recipe r INNER JOIN recipe_rating rr ON r.recipe_id = rr.recipe_id INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id @@ -127,7 +129,7 @@ BEGIN GROUP BY r.recipe_id HAVING average_rating >= p_min_rating ORDER BY average_rating DESC - LIMIT p_limit OFFSET v_offset; + LIMIT v_limit OFFSET v_offset; END // CREATE OR REPLACE PROCEDURE get_recipes_liked_by_person_paginated( @@ -136,11 +138,11 @@ CREATE OR REPLACE PROCEDURE get_recipes_liked_by_person_paginated( IN p_offset INT ) BEGIN - DECLARE v_max_limit INT DEFAULT 30; DECLARE v_offset INT; + DECLARE v_limit INT; - SET v_offset = (p_offset - 1) * p_limit; - SET p_limit = LEAST(p_limit, v_max_limit); + SET v_offset = calculate_offset(p_offset, p_limit); + SET v_limit = enforce_row_limit(p_limit); SELECT r.recipe_id, @@ -156,7 +158,7 @@ BEGIN INNER JOIN person p ON r.author_id = p.person_id WHERE re.person_id = p_person_id AND re.engagement_type = 'like' - LIMIT p_limit OFFSET v_offset; + LIMIT v_limit OFFSET v_offset; END // CREATE OR REPLACE PROCEDURE get_recipes_by_category_paginated( @@ -166,11 +168,11 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_category_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_max_limit INT DEFAULT 30; DECLARE v_offset INT; + DECLARE v_limit INT; - SET v_offset = (p_offset - 1) * p_limit; - SET p_limit = LEAST(p_limit, v_max_limit); + SET v_offset = calculate_offset(p_offset, p_limit); + SET v_limit = enforce_row_limit(p_limit); SELECT r.recipe_id, @@ -181,7 +183,7 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status, - rt.title + get_recipe_title(r.recipe_id, p_language_iso_code) AS title FROM recipe r INNER JOIN recipe_category rc ON r.recipe_id = rc.recipe_id INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id @@ -189,7 +191,7 @@ BEGIN INNER JOIN person p ON r.author_id = p.person_id WHERE rc.category_id = p_category_id AND l.iso_code = p_language_iso_code - LIMIT p_limit OFFSET v_offset; + LIMIT v_limit OFFSET v_offset; END // CREATE OR REPLACE PROCEDURE get_recipes_by_tags_paginated( @@ -199,11 +201,11 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_tags_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_max_limit INT DEFAULT 30; DECLARE v_offset INT; + DECLARE v_limit INT; - SET v_offset = (p_offset - 1) * p_limit; - SET p_limit = LEAST(p_limit, v_max_limit); + SET v_offset = calculate_offset(p_offset, p_limit); + SET v_limit = enforce_row_limit(p_limit); SELECT r.recipe_id, @@ -214,7 +216,7 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status, - rt.title + get_recipe_title(r.recipe_id, p_language_iso_code) AS title FROM recipe r INNER JOIN recipe_tag rtg ON r.recipe_id = rtg.recipe_id INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id @@ -222,7 +224,7 @@ BEGIN INNER JOIN person p ON r.author_id = p.person_id WHERE JSON_CONTAINS(p_tags, JSON_QUOTE(rtg.tag)) AND l.iso_code = p_language_iso_code - LIMIT p_limit OFFSET v_offset; + LIMIT v_limit OFFSET v_offset; END // CREATE OR REPLACE PROCEDURE get_recipes_by_name_paginated( @@ -232,11 +234,13 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_name_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_max_limit INT DEFAULT 30; DECLARE v_offset INT; + DECLARE v_limit INT; + DECLARE v_safe_recipe_name VARCHAR(255); - SET v_offset = (p_offset - 1) * p_limit; - SET p_limit = LEAST(p_limit, v_max_limit); + SET v_offset = calculate_offset(p_offset, p_limit); + SET v_limit = enforce_row_limit(p_limit); + SET v_safe_recipe_name = sanitize_string(p_name); SELECT r.recipe_id, @@ -247,14 +251,14 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status, - rt.title + get_recipe_title(r.recipe_id, p_language_iso_code) AS title FROM recipe r INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id INNER JOIN lang l ON rt.language_id = l.language_id INNER JOIN person p ON r.author_id = p.person_id WHERE rt.title LIKE v_safe_recipe_name ESCAPE '\\' AND l.iso_code = p_language_iso_code - LIMIT p_limit OFFSET v_offset; + LIMIT v_limit OFFSET v_offset; END // DELIMITER ; From c95c985a4475d4dd328af19d06746fd1f3950571 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 18:11:47 -0500 Subject: [PATCH 05/20] Refactor recipe procedures to centralize pagination logic and remove unused function --- functions/get_recipe_title.sql | 20 --- procedures/get/recipe.sql | 256 ++++++++++----------------------- 2 files changed, 79 insertions(+), 197 deletions(-) delete mode 100644 functions/get_recipe_title.sql diff --git a/functions/get_recipe_title.sql b/functions/get_recipe_title.sql deleted file mode 100644 index 058bfba..0000000 --- a/functions/get_recipe_title.sql +++ /dev/null @@ -1,20 +0,0 @@ --- Use the database -USE smartcooking; - -DELIMITER // - -CREATE FUNCTION get_recipe_title(p_recipe_id INT, p_language_iso_code CHAR(2)) -RETURNS VARCHAR(255) -DETERMINISTIC -BEGIN - DECLARE v_title VARCHAR(255); - SELECT rt.title - INTO v_title - FROM recipe_translation rt - INNER JOIN lang l ON rt.language_id = l.language_id - WHERE rt.recipe_id = p_recipe_id - AND l.language_iso_code = p_language_iso_code; - RETURN v_title; -END // - -DELIMITER ; diff --git a/procedures/get/recipe.sql b/procedures/get/recipe.sql index 31b92dc..bcd6bf7 100644 --- a/procedures/get/recipe.sql +++ b/procedures/get/recipe.sql @@ -3,70 +3,65 @@ USE smartcooking; DELIMITER // --- Testing procedure (unchanged as it does not benefit from the functions) -CREATE OR REPLACE PROCEDURE get_all_recipes() -BEGIN - SELECT * FROM recipe; -END // - --- Procedure to fetch recipe details by ID, using the `get_recipe_title` function -CREATE OR REPLACE PROCEDURE get_recipe_by_id( - IN p_recipe_id INT, - IN p_language_iso_code CHAR(2) +-- Centralized procedure for fetching paginated recipes with filtering +CREATE OR REPLACE PROCEDURE get_recipes_paginated( + IN p_filter_condition TEXT, + IN p_limit INT, + IN p_offset INT, + IN p_language_iso_code CHAR(2), + IN p_group_by TEXT, + IN p_having_condition TEXT, + IN p_order_by TEXT ) BEGIN - SELECT - r.author_id, - p.person_name AS author_name, - r.picture_id, - r.cook_time, - r.difficulty_level, - r.number_of_reviews, - r.recipe_status, - get_recipe_title(p_recipe_id, p_language_iso_code) AS title, - rt.details, - rt.preparation, - rt.nutritional_information, - rt.video_url - FROM recipe r - INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id - INNER JOIN lang l ON rt.language_id = l.language_id - INNER JOIN person p ON r.author_id = p.person_id - WHERE r.recipe_id = p_recipe_id - AND l.iso_code = p_language_iso_code; + DECLARE v_limit INT; + DECLARE v_offset INT; + SET v_limit = enforce_row_limit(p_limit); + SET v_offset = calculate_offset(p_offset, v_limit); + + SET @query = 'SELECT r.recipe_id, r.author_id, p.person_name AS author_name, ' + 'r.picture_id, r.cook_time, r.difficulty_level, r.number_of_reviews, ' + 'r.recipe_status, rt.title ' + 'FROM recipe r ' + 'INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id ' + 'INNER JOIN lang l ON rt.language_id = l.language_id ' + 'INNER JOIN person p ON r.author_id = p.person_id ' + 'WHERE l.iso_code = ? '; + + IF p_filter_condition IS NOT NULL THEN + SET @query = CONCAT(@query, p_filter_condition); + END IF; + + IF p_group_by IS NOT NULL THEN + SET @query = CONCAT(@query, ' ', p_group_by); + END IF; + + IF p_having_condition IS NOT NULL THEN + SET @query = CONCAT(@query, ' ', p_having_condition); + END IF; + + IF p_order_by IS NOT NULL THEN + SET @query = CONCAT(@query, ' ', p_order_by); + END IF; + + SET @query = CONCAT(@query, ' LIMIT ? OFFSET ?'); + + PREPARE stmt FROM @query; + EXECUTE stmt USING p_language_iso_code, v_limit, v_offset; + DEALLOCATE PREPARE stmt; END // --- Generic template for pagination with limit and offset +-- Procedure for retrieving all recipes with optional pagination CREATE OR REPLACE PROCEDURE get_all_recipes_paginated( IN p_limit INT, IN p_offset INT, IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_offset INT; - DECLARE v_limit INT; - - SET v_offset = calculate_offset(p_offset, p_limit); - SET v_limit = enforce_row_limit(p_limit); - - SELECT - r.recipe_id, - r.author_id, - p.person_name AS author_name, - r.picture_id, - r.cook_time, - r.difficulty_level, - r.number_of_reviews, - r.recipe_status, - get_recipe_title(r.recipe_id, p_language_iso_code) AS title - FROM recipe r - INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id - INNER JOIN lang l ON rt.language_id = l.language_id - INNER JOIN person p ON r.author_id = p.person_id - WHERE l.iso_code = p_language_iso_code - LIMIT v_limit OFFSET v_offset; + CALL get_recipes_paginated(NULL, p_limit, p_offset, p_language_iso_code, NULL, NULL, NULL); END // +-- Procedure for retrieving recipes by author with pagination CREATE OR REPLACE PROCEDURE get_recipes_by_author_paginated( IN p_author_id INT, IN p_limit INT, @@ -74,28 +69,10 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_author_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_offset INT; - DECLARE v_limit INT; - - SET v_offset = calculate_offset(p_offset, p_limit); - SET v_limit = enforce_row_limit(p_limit); - - SELECT - r.recipe_id, - r.picture_id, - r.cook_time, - r.difficulty_level, - r.number_of_reviews, - r.recipe_status, - get_recipe_title(r.recipe_id, p_language_iso_code) AS title - FROM recipe r - INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id - INNER JOIN lang l ON rt.language_id = l.language_id - WHERE r.author_id = p_author_id - AND l.iso_code = p_language_iso_code - LIMIT v_limit OFFSET v_offset; + CALL get_recipes_paginated('AND r.author_id = ?', p_limit, p_offset, p_language_iso_code, NULL, NULL, NULL); END // +-- Procedure for retrieving top-rated recipes with pagination CREATE OR REPLACE PROCEDURE get_top_rated_recipes_paginated( IN p_min_rating TINYINT, IN p_limit INT, @@ -103,46 +80,25 @@ CREATE OR REPLACE PROCEDURE get_top_rated_recipes_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_offset INT; - DECLARE v_limit INT; - - SET v_offset = calculate_offset(p_offset, p_limit); - SET v_limit = enforce_row_limit(p_limit); - - SELECT - r.recipe_id, - r.author_id, - p.person_name AS author_name, - r.picture_id, - r.cook_time, - r.difficulty_level, - r.number_of_reviews, - r.recipe_status, - AVG(rr.rating) AS average_rating, - get_recipe_title(r.recipe_id, p_language_iso_code) AS title - FROM recipe r - INNER JOIN recipe_rating rr ON r.recipe_id = rr.recipe_id - INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id - INNER JOIN lang l ON rt.language_id = l.language_id - INNER JOIN person p ON r.author_id = p.person_id - WHERE l.iso_code = p_language_iso_code - GROUP BY r.recipe_id - HAVING average_rating >= p_min_rating - ORDER BY average_rating DESC - LIMIT v_limit OFFSET v_offset; + CALL get_recipes_paginated( + 'INNER JOIN recipe_rating rr ON r.recipe_id = rr.recipe_id', + p_limit, p_offset, p_language_iso_code, 'GROUP BY r.recipe_id', + 'HAVING AVG(rr.rating) >= ?', + 'ORDER BY AVG(rr.rating) DESC' + ); END // +-- Procedure for retrieving recipes liked by a person with pagination CREATE OR REPLACE PROCEDURE get_recipes_liked_by_person_paginated( IN p_person_id INT, IN p_limit INT, IN p_offset INT ) BEGIN - DECLARE v_offset INT; DECLARE v_limit INT; - - SET v_offset = calculate_offset(p_offset, p_limit); + DECLARE v_offset INT; SET v_limit = enforce_row_limit(p_limit); + SET v_offset = calculate_offset(p_offset, v_limit); SELECT r.recipe_id, @@ -153,14 +109,15 @@ BEGIN r.difficulty_level, r.number_of_reviews, r.recipe_status - FROM recipe r - INNER JOIN recipe_engagement re ON r.recipe_id = re.recipe_id - INNER JOIN person p ON r.author_id = p.person_id - WHERE re.person_id = p_person_id - AND re.engagement_type = 'like' + FROM + recipe r + INNER JOIN recipe_engagement re ON r.recipe_id = re.recipe_id + INNER JOIN person p ON r.author_id = p.person_id + WHERE re.person_id = p_person_id AND re.engagement_type = 'like' LIMIT v_limit OFFSET v_offset; END // +-- Procedure for retrieving recipes by category with pagination CREATE OR REPLACE PROCEDURE get_recipes_by_category_paginated( IN p_category_id INT, IN p_limit INT, @@ -168,32 +125,13 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_category_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_offset INT; - DECLARE v_limit INT; - - SET v_offset = calculate_offset(p_offset, p_limit); - SET v_limit = enforce_row_limit(p_limit); - - SELECT - r.recipe_id, - r.author_id, - p.person_name AS author_name, - r.picture_id, - r.cook_time, - r.difficulty_level, - r.number_of_reviews, - r.recipe_status, - get_recipe_title(r.recipe_id, p_language_iso_code) AS title - FROM recipe r - INNER JOIN recipe_category rc ON r.recipe_id = rc.recipe_id - INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id - INNER JOIN lang l ON rt.language_id = l.language_id - INNER JOIN person p ON r.author_id = p.person_id - WHERE rc.category_id = p_category_id - AND l.iso_code = p_language_iso_code - LIMIT v_limit OFFSET v_offset; + CALL get_recipes_paginated( + 'INNER JOIN recipe_category rc ON r.recipe_id = rc.recipe_id AND rc.category_id = ?', + p_limit, p_offset, p_language_iso_code, NULL, NULL, NULL + ); END // +-- Procedure for retrieving recipes by tags with pagination CREATE OR REPLACE PROCEDURE get_recipes_by_tags_paginated( IN p_tags JSON, IN p_limit INT, @@ -201,32 +139,14 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_tags_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_offset INT; - DECLARE v_limit INT; - - SET v_offset = calculate_offset(p_offset, p_limit); - SET v_limit = enforce_row_limit(p_limit); - - SELECT - r.recipe_id, - r.author_id, - p.person_name AS author_name, - r.picture_id, - r.cook_time, - r.difficulty_level, - r.number_of_reviews, - r.recipe_status, - get_recipe_title(r.recipe_id, p_language_iso_code) AS title - FROM recipe r - INNER JOIN recipe_tag rtg ON r.recipe_id = rtg.recipe_id - INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id - INNER JOIN lang l ON rt.language_id = l.language_id - INNER JOIN person p ON r.author_id = p.person_id - WHERE JSON_CONTAINS(p_tags, JSON_QUOTE(rtg.tag)) - AND l.iso_code = p_language_iso_code - LIMIT v_limit OFFSET v_offset; + CALL get_recipes_paginated( + 'INNER JOIN recipe_tag rtg ON r.recipe_id = rtg.recipe_id ' + 'AND JSON_CONTAINS(?, JSON_QUOTE(rtg.tag))', + p_limit, p_offset, p_language_iso_code, NULL, NULL, NULL + ); END // +-- Procedure for retrieving recipes by name with pagination CREATE OR REPLACE PROCEDURE get_recipes_by_name_paginated( IN p_name VARCHAR(255), IN p_limit INT, @@ -234,31 +154,13 @@ CREATE OR REPLACE PROCEDURE get_recipes_by_name_paginated( IN p_language_iso_code CHAR(2) ) BEGIN - DECLARE v_offset INT; - DECLARE v_limit INT; DECLARE v_safe_recipe_name VARCHAR(255); - - SET v_offset = calculate_offset(p_offset, p_limit); - SET v_limit = enforce_row_limit(p_limit); SET v_safe_recipe_name = sanitize_string(p_name); - SELECT - r.recipe_id, - r.author_id, - p.person_name AS author_name, - r.picture_id, - r.cook_time, - r.difficulty_level, - r.number_of_reviews, - r.recipe_status, - get_recipe_title(r.recipe_id, p_language_iso_code) AS title - FROM recipe r - INNER JOIN recipe_translation rt ON r.recipe_id = rt.recipe_id - INNER JOIN lang l ON rt.language_id = l.language_id - INNER JOIN person p ON r.author_id = p.person_id - WHERE rt.title LIKE v_safe_recipe_name ESCAPE '\\' - AND l.iso_code = p_language_iso_code - LIMIT v_limit OFFSET v_offset; + CALL get_recipes_paginated( + 'AND rt.title LIKE ?', + p_limit, p_offset, p_language_iso_code, NULL, NULL, NULL + ); END // DELIMITER ; From a2197177656bf474f1a125956d00074a1cd41be8 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 22:50:26 -0500 Subject: [PATCH 06/20] Add recipe_status table and insert procedure for managing recipe statuses --- database.sql | 10 ++++++++-- procedures/insert/recipe_status.sql | 13 +++++++++++++ setup/recipe_status.sql | 13 +++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 procedures/insert/recipe_status.sql create mode 100644 setup/recipe_status.sql diff --git a/database.sql b/database.sql index 4c1adf7..76c8af9 100644 --- a/database.sql +++ b/database.sql @@ -86,6 +86,11 @@ CREATE OR REPLACE TABLE ingredient_translation ( FOREIGN KEY (language_id) REFERENCES lang (language_id) ON DELETE CASCADE ) ENGINE = InnoDB; +CREATE TABLE recipe_status ( + id TINYINT AUTO_INCREMENT PRIMARY KEY, + status_name VARCHAR(25) UNIQUE NOT NULL +) ENGINE = InnoDB; + CREATE OR REPLACE TABLE recipe ( recipe_id INT AUTO_INCREMENT PRIMARY KEY, author_id INT NULL, @@ -96,9 +101,10 @@ CREATE OR REPLACE TABLE recipe ( difficulty_level TINYINT CHECK (difficulty_level BETWEEN 1 AND 3), number_of_reviews INT NULL, source VARCHAR(255) NULL, - recipe_status ENUM('draft', 'published', 'hidden', 'archived', 'pending review', 'rejected', 'scheduled', 'needs update', 'unlisted', 'deleted') NOT NULL DEFAULT 'draft', + recipe_status TINYINT NOT NULL DEFAULT 1, FOREIGN KEY (author_id) REFERENCES person (person_id) ON DELETE SET NULL, - FOREIGN KEY (picture_id) REFERENCES picture (picture_id) ON DELETE CASCADE + FOREIGN KEY (picture_id) REFERENCES picture (picture_id) ON DELETE CASCADE, + FOREIGN KEY (recipe_status) REFERENCES recipe_status (id) ON DELETE RESTRICT ) ENGINE = InnoDB; CREATE OR REPLACE TABLE recipe_ingredient ( diff --git a/procedures/insert/recipe_status.sql b/procedures/insert/recipe_status.sql new file mode 100644 index 0000000..c7d8d13 --- /dev/null +++ b/procedures/insert/recipe_status.sql @@ -0,0 +1,13 @@ +-- Use the database +USE smartcooking; + +DELIMITER // + +CREATE OR REPLACE PROCEDURE insert_recipe_status( + IN p_status_name VARCHAR(25) +) +BEGIN + INSERT INTO recipe_status (status_name) VALUES (p_status_name); +END // + +DELIMITER ; diff --git a/setup/recipe_status.sql b/setup/recipe_status.sql new file mode 100644 index 0000000..27f8ba6 --- /dev/null +++ b/setup/recipe_status.sql @@ -0,0 +1,13 @@ +-- Use the database +USE smartcooking; + +CALL insert_recipe_status('draft'); -- ID 1 is the default status +CALL insert_recipe_status('published'); +CALL insert_recipe_status('hidden'); +CALL insert_recipe_status('archived'); +CALL insert_recipe_status('pending review'); +CALL insert_recipe_status('rejected'); +CALL insert_recipe_status('scheduled'); +CALL insert_recipe_status('needs update'); +CALL insert_recipe_status('unlisted'); +CALL insert_recipe_status('deleted'); From d51713234a4eda76d8228db76ca66ae0847dcb69 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 22:55:03 -0500 Subject: [PATCH 07/20] Add recipe_status table and procedures for retrieving status by ID and name --- database.sql | 2 +- procedures/get/recipe_status.sql | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 procedures/get/recipe_status.sql diff --git a/database.sql b/database.sql index 76c8af9..5fffd11 100644 --- a/database.sql +++ b/database.sql @@ -87,7 +87,7 @@ CREATE OR REPLACE TABLE ingredient_translation ( ) ENGINE = InnoDB; CREATE TABLE recipe_status ( - id TINYINT AUTO_INCREMENT PRIMARY KEY, + status_id TINYINT AUTO_INCREMENT PRIMARY KEY, status_name VARCHAR(25) UNIQUE NOT NULL ) ENGINE = InnoDB; diff --git a/procedures/get/recipe_status.sql b/procedures/get/recipe_status.sql new file mode 100644 index 0000000..4603720 --- /dev/null +++ b/procedures/get/recipe_status.sql @@ -0,0 +1,24 @@ +-- Use the database +USE smartcooking; + +DELIMITER // + +CREATE OR REPLACE PROCEDURE get_recipe_status( + IN p_status_id INT +) +BEGIN + SELECT status_name + FROM recipe_status + WHERE status_id = p_status_id; +END // + +CREATE OR REPLACE PROCEDURE get_recipe_status_by_name( + IN p_status_name VARCHAR(25) +) +BEGIN + SELECT status_id + FROM recipe_status + WHERE status_name = p_status_name; +END // + +DELIMITER ; From a56c80493570f603fd8851021a34ad736f41e769 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:05:36 -0500 Subject: [PATCH 08/20] Refactor mock data insertion for recipe ingredients and translations for improved readability --- setup/responsibility.sql | 166 ++++++++++++++++++----- setup/z_mock/recipe_ingredient.sql | 12 +- setup/z_mock/recipe_translation.sql | 199 +++++++++++++++++++++++++--- 3 files changed, 322 insertions(+), 55 deletions(-) diff --git a/setup/responsibility.sql b/setup/responsibility.sql index 9d83aa2..794d2de 100644 --- a/setup/responsibility.sql +++ b/setup/responsibility.sql @@ -2,54 +2,154 @@ USE smartcooking; -- Administrative -CALL insert_responsibility('can_manage_roles', 'Allows the ability to create, edit, or delete user roles and their associated permissions.'); -CALL insert_responsibility('can_view_audit_log', 'Allows access to view detailed records of database activities and changes for auditing purposes.'); +CALL insert_responsibility( + 'can_manage_roles', + 'Allows the ability to create, edit, or delete user roles and their associated permissions.' +); +CALL insert_responsibility( + 'can_view_audit_log', + 'Allows access to view detailed records of database activities' || + ' and changes for auditing purposes.' +); -- Category management -CALL insert_responsibility('can_create_category', 'Grants the ability to create new categories for organizing content.'); -CALL insert_responsibility('can_edit_category', 'Allows editing existing categories to update their details.'); -CALL insert_responsibility('can_delete_category', 'Grants permission to remove categories from the database.'); +CALL insert_responsibility( + 'can_create_category', + 'Grants the ability to create new categories for organizing content.' +); +CALL insert_responsibility( + 'can_edit_category', + 'Allows editing existing categories to update their details.' +); +CALL insert_responsibility( + 'can_delete_category', + 'Grants permission to remove categories from the database.' +); -- Comment management -CALL insert_responsibility('can_comment_on_recipe', 'Enables the user to post comments on recipes.'); -CALL insert_responsibility('can_edit_own_comment', 'Allows users to edit their own comments.'); -CALL insert_responsibility('can_edit_any_comment', 'Grants the ability to modify any comment in the system.'); -CALL insert_responsibility('can_delete_own_comment', 'Enables users to delete their own comments.'); -CALL insert_responsibility('can_delete_any_comment', 'Grants the ability to remove any comment from the system.'); +CALL insert_responsibility( + 'can_comment_on_recipe', + 'Enables the user to post comments on recipes.' +); +CALL insert_responsibility( + 'can_edit_own_comment', + 'Allows users to edit their own comments.' +); +CALL insert_responsibility( + 'can_edit_any_comment', + 'Grants the ability to modify any comment in the system.' +); +CALL insert_responsibility( + 'can_delete_own_comment', + 'Enables users to delete their own comments.' +); +CALL insert_responsibility( + 'can_delete_any_comment', + 'Grants the ability to remove any comment from the system.' +); -- Ingredient management -CALL insert_responsibility('can_create_ingredient', 'Allows the addition of new ingredients to the database.'); -CALL insert_responsibility('can_edit_ingredient', 'Grants permission to modify existing ingredient details.'); -CALL insert_responsibility('can_delete_ingredient', 'Allows the removal of ingredients from the database.'); +CALL insert_responsibility( + 'can_create_ingredient', + 'Allows the addition of new ingredients to the database.' +); +CALL insert_responsibility( + 'can_edit_ingredient', + 'Grants permission to modify existing ingredient details.' +); +CALL insert_responsibility( + 'can_delete_ingredient', + 'Allows the removal of ingredients from the database.' +); -- Media management -CALL insert_responsibility('can_upload_picture', 'Enables users to upload pictures to the system.'); -CALL insert_responsibility('can_delete_picture', 'Grants the ability to remove pictures from the system.'); +CALL insert_responsibility( + 'can_upload_picture', + 'Enables users to upload pictures to the system.' +); +CALL insert_responsibility( + 'can_delete_picture', + 'Grants the ability to remove pictures from the system.' +); -- Moderation -CALL insert_responsibility('can_review_flagged_content', 'Allows reviewing and managing content flagged as inappropriate.'); -CALL insert_responsibility('can_suspend_user_account', 'Grants the ability to temporarily suspend a user’s account.'); -CALL insert_responsibility('can_ban_user_account', 'Enables the banning of user accounts permanently.'); +CALL insert_responsibility( + 'can_review_flagged_content', + 'Allows reviewing and managing content flagged as inappropriate.' +); +CALL insert_responsibility( + 'can_suspend_user_account', + 'Grants the ability to temporarily suspend a user’s account.' +); +CALL insert_responsibility( + 'can_ban_user_account', + 'Enables the banning of user accounts permanently.' +); -- Person management -CALL insert_responsibility('can_manage_any_person_profile', 'Grants access to edit profiles of any user in the system.'); -CALL insert_responsibility('can_delete_any_person_account', 'Allows the permanent removal of any user account.'); +CALL insert_responsibility( + 'can_manage_any_person_profile', + 'Grants access to edit profiles of any user in the system.' +); +CALL insert_responsibility( + 'can_delete_any_person_account', + 'Allows the permanent removal of any user account.' +); -- Recipe management -CALL insert_responsibility('can_create_recipe', 'Allows users to create and submit new recipes.'); -CALL insert_responsibility('can_edit_own_recipe', 'Grants users the ability to edit their own recipes.'); -CALL insert_responsibility('can_edit_any_recipe', 'Allows editing any recipe in the system.'); -CALL insert_responsibility('can_delete_own_recipe', 'Enables users to delete their own recipes.'); -CALL insert_responsibility('can_delete_any_recipe', 'Grants the ability to remove any recipe from the system.'); -CALL insert_responsibility('can_publish_recipe', 'Allows the publication of recipes to make them publicly visible.'); -CALL insert_responsibility('can_review_recipe', 'Grants permission to review recipes for approval or feedback.'); +CALL insert_responsibility( + 'can_create_recipe', + 'Allows users to create and submit new recipes.' +); +CALL insert_responsibility( + 'can_edit_own_recipe', + 'Grants users the ability to edit their own recipes.' +); +CALL insert_responsibility( + 'can_edit_any_recipe', + 'Allows editing any recipe in the system.' +); +CALL insert_responsibility( + 'can_delete_own_recipe', + 'Enables users to delete their own recipes.' +); +CALL insert_responsibility( + 'can_delete_any_recipe', + 'Grants the ability to remove any recipe from the system.' +); +CALL insert_responsibility( + 'can_publish_recipe', + 'Allows the publication of recipes to make them publicly visible.' +); +CALL insert_responsibility( + 'can_review_recipe', + 'Grants permission to review recipes for approval or feedback.' +); -- Tag management -CALL insert_responsibility('can_create_tag', 'Allows the creation of new tags for categorizing content.'); -CALL insert_responsibility('can_edit_tag', 'Grants the ability to edit existing tags.'); -CALL insert_responsibility('can_delete_tag', 'Allows the removal of tags from the database.'); +CALL insert_responsibility( + 'can_create_tag', + 'Allows the creation of new tags for categorizing content.' +); +CALL insert_responsibility( + 'can_edit_tag', + 'Grants the ability to edit existing tags.' +); +CALL insert_responsibility( + 'can_delete_tag', + 'Allows the removal of tags from the database.' +); -- Translation management -CALL insert_responsibility('can_add_translation', 'Enables the addition of new translations for system content.'); -CALL insert_responsibility('can_edit_translation', 'Grants permission to modify existing translations.'); -CALL insert_responsibility('can_delete_translation', 'Allows the deletion of translations from the database.'); +CALL insert_responsibility( + 'can_add_translation', + 'Enables the addition of new translations for system content.' +); +CALL insert_responsibility( + 'can_edit_translation', + 'Grants permission to modify existing translations.' +); +CALL insert_responsibility( + 'can_delete_translation', + 'Allows the deletion of translations from the database.' +); diff --git a/setup/z_mock/recipe_ingredient.sql b/setup/z_mock/recipe_ingredient.sql index 90ae621..09d96c8 100644 --- a/setup/z_mock/recipe_ingredient.sql +++ b/setup/z_mock/recipe_ingredient.sql @@ -4,5 +4,13 @@ USE smartcooking; -- Fill the database with mock data CALL insert_recipe_ingredient(1, 1, 2, 'g'); CALL insert_recipe_ingredient_by_name(1, 'Sugar', 1, 'tsp'); -CALL insert_recipe_ingredients(2, '[{"ingredient_id": 1, "quantity": 2, "unit": "g"}, {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]'); -CALL insert_recipe_ingredients_by_name(3, '[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"}, {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]'); +CALL insert_recipe_ingredients( + 2, + '[{"ingredient_id": 1, "quantity": 2, "unit": "g"},' || + ' {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]' +); +CALL insert_recipe_ingredients_by_name( + 3, + '[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"},' || + ' {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]' +); diff --git a/setup/z_mock/recipe_translation.sql b/setup/z_mock/recipe_translation.sql index 92e47f1..c6c824b 100644 --- a/setup/z_mock/recipe_translation.sql +++ b/setup/z_mock/recipe_translation.sql @@ -2,23 +2,182 @@ USE smartcooking; -- Fill the database with mock data -CALL insert_recipe_translation_by_iso_code(1, 'en', 'Title 1', 'Details 1', 'Preparation 1', 'Nutritional information 1', 'www.video.com'); -CALL insert_recipe_translation_by_iso_code(1, 'es', 'Título 1', 'Detalles 1', 'Preparación 1', 'Información nutricional 1', 'www.video_es.com'); -CALL insert_recipe_translation_by_iso_code(1, 'fr', 'Titre 1', 'Détails 1', 'Préparation 1', 'Informations nutritionnelles 1', 'www.video_fr.com'); -CALL insert_recipe_translation_by_iso_code(1, 'ko', '제목 1', '세부 정보 1', '준비 1', '영양 정보 1', 'www.video_ko.com'); -CALL insert_recipe_translation_by_iso_code(2, 'en', 'Title 2', 'Details 2', 'Preparation 2', 'Nutritional information 2', 'www.video.com'); -CALL insert_recipe_translation_by_iso_code(2, 'es', 'Título 2', 'Detalles 2', 'Preparación 2', 'Información nutricional 2', 'www.video_es.com'); -CALL insert_recipe_translation_by_iso_code(2, 'fr', 'Titre 2', 'Détails 2', 'Préparation 2', 'Informations nutritionnelles 2', 'www.video_fr.com'); -CALL insert_recipe_translation_by_iso_code(2, 'ko', '제목 2', '세부 정보 2', '준비 2', '영양 정보 2', 'www.video_ko.com'); -CALL insert_recipe_translation_by_iso_code(3, 'en', 'Title 3', 'Details 3', 'Preparation 3', 'Nutritional information 3', 'www.video.com'); -CALL insert_recipe_translation_by_iso_code(3, 'es', 'Título 3', 'Detalles 3', 'Preparación 3', 'Información nutricional 3', 'www.video_es.com'); -CALL insert_recipe_translation_by_iso_code(3, 'fr', 'Titre 3', 'Détails 3', 'Préparation 3', 'Informations nutritionnelles 3', 'www.video_fr.com'); -CALL insert_recipe_translation_by_iso_code(3, 'ko', '제목 3', '세부 정보 3', '준비 3', '영양 정보 3', 'www.video_ko.com'); -CALL insert_recipe_translation_by_iso_code(4, 'en', 'Title 4', 'Details 4', 'Preparation 4', 'Nutritional information 4', 'www.video.com'); -CALL insert_recipe_translation_by_iso_code(4, 'es', 'Título 4', 'Detalles 4', 'Preparación 4', 'Información nutricional 4', 'www.video_es.com'); -CALL insert_recipe_translation_by_iso_code(4, 'fr', 'Titre 4', 'Détails 4', 'Préparation 4', 'Informations nutritionnelles 4', 'www.video_fr.com'); -CALL insert_recipe_translation_by_iso_code(4, 'ko', '제목 4', '세부 정보 4', '준비 4', '영양 정보 4', 'www.video_ko.com'); -CALL insert_recipe_translation_by_iso_code(5, 'en', 'Title 5', 'Details 5', 'Preparation 5', 'Nutritional information 5', 'www.video.com'); -CALL insert_recipe_translation_by_iso_code(5, 'es', 'Título 5', 'Detalles 5', 'Preparación 5', 'Información nutricional 5', 'www.video_es.com'); -CALL insert_recipe_translation_by_iso_code(5, 'fr', 'Titre 5', 'Détails 5', 'Préparation 5', 'Informations nutritionnelles 5', 'www.video_fr.com'); -CALL insert_recipe_translation_by_iso_code(5, 'ko', '제목 5', '세부 정보 5', '준비 5', '영양 정보 5', 'www.video_ko.com'); +CALL insert_recipe_translation_by_iso_code( + 1, 'en', + 'Title 1', + 'Details 1', + 'Preparation 1', + 'Nutritional information 1', + 'www.video.com' +); + +CALL insert_recipe_translation_by_iso_code( + 1, 'es', + 'Título 1', + 'Detalles 1', + 'Preparación 1', + 'Información nutricional 1', + 'www.video_es.com' +); + +CALL insert_recipe_translation_by_iso_code( + 1, 'fr', + 'Titre 1', + 'Détails 1', + 'Préparation 1', + 'Informations nutritionnelles 1', + 'www.video_fr.com' +); + +CALL insert_recipe_translation_by_iso_code( + 1, 'ko', + '제목 1', + '세부 정보 1', + '준비 1', + '영양 정보 1', + 'www.video_ko.com' +); + +CALL insert_recipe_translation_by_iso_code( + 2, 'en', + 'Title 2', + 'Details 2', + 'Preparation 2', + 'Nutritional information 2', + 'www.video.com' +); + +CALL insert_recipe_translation_by_iso_code( + 2, 'es', + 'Título 2', + 'Detalles 2', + 'Preparación 2', + 'Información nutricional 2', + 'www.video_es.com' +); + +CALL insert_recipe_translation_by_iso_code( + 2, 'fr', + 'Titre 2', + 'Détails 2', + 'Préparation 2', + 'Informations nutritionnelles 2', + 'www.video_fr.com' +); + +CALL insert_recipe_translation_by_iso_code( + 2, 'ko', + '제목 2', + '세부 정보 2', + '준비 2', + '영양 정보 2', + 'www.video_ko.com' +); + +CALL insert_recipe_translation_by_iso_code( + 3, 'en', + 'Title 3', + 'Details 3', + 'Preparation 3', + 'Nutritional information 3', + 'www.video.com' +); + +CALL insert_recipe_translation_by_iso_code( + 3, 'es', + 'Título 3', + 'Detalles 3', + 'Preparación 3', + 'Información nutricional 3', + 'www.video_es.com' +); + +CALL insert_recipe_translation_by_iso_code( + 3, 'fr', + 'Titre 3', + 'Détails 3', + 'Préparation 3', + 'Informations nutritionnelles 3', + 'www.video_fr.com' +); + +CALL insert_recipe_translation_by_iso_code( + 3, 'ko', + '제목 3', + '세부 정보 3', + '준비 3', + '영양 정보 3', + 'www.video_ko.com' +); + +CALL insert_recipe_translation_by_iso_code( + 4, 'en', + 'Title 4', + 'Details 4', + 'Preparation 4', + 'Nutritional information 4', + 'www.video.com' +); + +CALL insert_recipe_translation_by_iso_code( + 4, 'es', + 'Título 4', + 'Detalles 4', + 'Preparación 4', + 'Información nutricional 4', + 'www.video_es.com' +); + +CALL insert_recipe_translation_by_iso_code( + 4, 'fr', + 'Titre 4', + 'Détails 4', + 'Préparation 4', + 'Informations nutritionnelles 4', + 'www.video_fr.com' +); + +CALL insert_recipe_translation_by_iso_code( + 4, 'ko', + '제목 4', + '세부 정보 4', + '준비 4', + '영양 정보 4', + 'www.video_ko.com' +); + +CALL insert_recipe_translation_by_iso_code( + 5, 'en', + 'Title 5', + 'Details 5', + 'Preparation 5', + 'Nutritional information 5', + 'www.video.com' +); + +CALL insert_recipe_translation_by_iso_code( + 5, 'es', + 'Título 5', + 'Detalles 5', + 'Preparación 5', + 'Información nutricional 5', + 'www.video_es.com' +); + +CALL insert_recipe_translation_by_iso_code( + 5, 'fr', + 'Titre 5', + 'Détails 5', + 'Préparation 5', + 'Informations nutritionnelles 5', + 'www.video_fr.com' +); + +CALL insert_recipe_translation_by_iso_code( + 5, 'ko', + '제목 5', + '세부 정보 5', + '준비 5', + '영양 정보 5', + 'www.video_ko.com' +); From 94a61198779e0f93d9cba4c0e7030007a29164dd Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:14:05 -0500 Subject: [PATCH 09/20] Rename 'source' to 'recipe_source' in recipe table and procedures for consistency; update mock data insertion to use unhex function --- database.sql | 2 +- procedures/insert/recipe.sql | 6 +++--- setup/responsibility.sql | 3 +-- setup/z_mock/person.sql | 8 ++++---- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/database.sql b/database.sql index 5fffd11..a039065 100644 --- a/database.sql +++ b/database.sql @@ -100,7 +100,7 @@ CREATE OR REPLACE TABLE recipe ( cook_time INT UNSIGNED NULL, difficulty_level TINYINT CHECK (difficulty_level BETWEEN 1 AND 3), number_of_reviews INT NULL, - source VARCHAR(255) NULL, + recipe_source VARCHAR(255) NULL, recipe_status TINYINT NOT NULL DEFAULT 1, FOREIGN KEY (author_id) REFERENCES person (person_id) ON DELETE SET NULL, FOREIGN KEY (picture_id) REFERENCES picture (picture_id) ON DELETE CASCADE, diff --git a/procedures/insert/recipe.sql b/procedures/insert/recipe.sql index 30534cf..a76bfcc 100644 --- a/procedures/insert/recipe.sql +++ b/procedures/insert/recipe.sql @@ -8,7 +8,7 @@ CREATE OR REPLACE PROCEDURE insert_recipe( IN picture_id INT, IN cook_time INT, IN difficulty_level TINYINT, - IN source VARCHAR(255), + IN recipe_source VARCHAR(255), IN recipe_status VARCHAR(20) ) BEGIN @@ -16,8 +16,8 @@ BEGIN SET recipe_status = 'pending review'; END IF; - INSERT INTO recipe (author_id, picture_id, cook_time, difficulty_level, source, recipe_status) - VALUES (author_id, picture_id, cook_time, difficulty_level, source, recipe_status); + INSERT INTO recipe (author_id, picture_id, cook_time, difficulty_level, recipe_source, recipe_status) + VALUES (author_id, picture_id, cook_time, difficulty_level, recipe_source, recipe_status); END // DELIMITER ; diff --git a/setup/responsibility.sql b/setup/responsibility.sql index 794d2de..a29c94f 100644 --- a/setup/responsibility.sql +++ b/setup/responsibility.sql @@ -8,8 +8,7 @@ CALL insert_responsibility( ); CALL insert_responsibility( 'can_view_audit_log', - 'Allows access to view detailed records of database activities' || - ' and changes for auditing purposes.' + 'Allows access to view detailed records of database activities and changes for auditing purposes.' ); -- Category management diff --git a/setup/z_mock/person.sql b/setup/z_mock/person.sql index 3bb1137..ca3f26a 100644 --- a/setup/z_mock/person.sql +++ b/setup/z_mock/person.sql @@ -2,7 +2,7 @@ USE smartcooking; -- Fill the database with mock data -CALL register_person('John Doe', 'john.doe@mock.data', 'password', UNHEX('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6'), 'en'); -CALL register_person('Jane Smith', 'jane.smith@mock.data', 'password', UNHEX('f1e2d3c4b5a6978899aabbccddeeff00'), 'fr'); -CALL register_person('Alice Brown', 'alice.brown@mock.data', 'password', UNHEX('0123456789abcdef0123456789abcdef'), 'es'); -CALL register_person('Bob White', 'bob.white@mock.data', 'password', UNHEX('fedcba9876543210fedcba9876543210'), 'en'); +CALL register_person('John Doe', 'john.doe@mock.data', 'password', unhex('a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6'), 'en'); +CALL register_person('Jane Smith', 'jane.smith@mock.data', 'password', unhex('f1e2d3c4b5a6978899aabbccddeeff00'), 'fr'); +CALL register_person('Alice Brown', 'alice.brown@mock.data', 'password', unhex('0123456789abcdef0123456789abcdef'), 'es'); +CALL register_person('Bob White', 'bob.white@mock.data', 'password', unhex('fedcba9876543210fedcba9876543210'), 'en'); From c7b5c3b868fab7e39d3476c3305dabbce580fe80 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:15:16 -0500 Subject: [PATCH 10/20] Refactor mock data insertion for recipe ingredients to improve readability by consolidating JSON strings --- setup/z_mock/recipe_ingredient.sql | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/setup/z_mock/recipe_ingredient.sql b/setup/z_mock/recipe_ingredient.sql index 09d96c8..762aab4 100644 --- a/setup/z_mock/recipe_ingredient.sql +++ b/setup/z_mock/recipe_ingredient.sql @@ -5,12 +5,8 @@ USE smartcooking; CALL insert_recipe_ingredient(1, 1, 2, 'g'); CALL insert_recipe_ingredient_by_name(1, 'Sugar', 1, 'tsp'); CALL insert_recipe_ingredients( - 2, - '[{"ingredient_id": 1, "quantity": 2, "unit": "g"},' || - ' {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]' + 2, '[{"ingredient_id": 1, "quantity": 2, "unit": "g"}, {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]' ); CALL insert_recipe_ingredients_by_name( - 3, - '[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"},' || - ' {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]' + 3, '[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"}, {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]' ); From cdcb8e0d56256d6b68aa6ebc6e35decd32f056da Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:23:00 -0500 Subject: [PATCH 11/20] Refactor responsibility insertion calls for improved readability by consolidating SQL statements --- setup/responsibility.sql | 165 ++++++++------------------------------- 1 file changed, 33 insertions(+), 132 deletions(-) diff --git a/setup/responsibility.sql b/setup/responsibility.sql index a29c94f..9d83aa2 100644 --- a/setup/responsibility.sql +++ b/setup/responsibility.sql @@ -2,153 +2,54 @@ USE smartcooking; -- Administrative -CALL insert_responsibility( - 'can_manage_roles', - 'Allows the ability to create, edit, or delete user roles and their associated permissions.' -); -CALL insert_responsibility( - 'can_view_audit_log', - 'Allows access to view detailed records of database activities and changes for auditing purposes.' -); +CALL insert_responsibility('can_manage_roles', 'Allows the ability to create, edit, or delete user roles and their associated permissions.'); +CALL insert_responsibility('can_view_audit_log', 'Allows access to view detailed records of database activities and changes for auditing purposes.'); -- Category management -CALL insert_responsibility( - 'can_create_category', - 'Grants the ability to create new categories for organizing content.' -); -CALL insert_responsibility( - 'can_edit_category', - 'Allows editing existing categories to update their details.' -); -CALL insert_responsibility( - 'can_delete_category', - 'Grants permission to remove categories from the database.' -); +CALL insert_responsibility('can_create_category', 'Grants the ability to create new categories for organizing content.'); +CALL insert_responsibility('can_edit_category', 'Allows editing existing categories to update their details.'); +CALL insert_responsibility('can_delete_category', 'Grants permission to remove categories from the database.'); -- Comment management -CALL insert_responsibility( - 'can_comment_on_recipe', - 'Enables the user to post comments on recipes.' -); -CALL insert_responsibility( - 'can_edit_own_comment', - 'Allows users to edit their own comments.' -); -CALL insert_responsibility( - 'can_edit_any_comment', - 'Grants the ability to modify any comment in the system.' -); -CALL insert_responsibility( - 'can_delete_own_comment', - 'Enables users to delete their own comments.' -); -CALL insert_responsibility( - 'can_delete_any_comment', - 'Grants the ability to remove any comment from the system.' -); +CALL insert_responsibility('can_comment_on_recipe', 'Enables the user to post comments on recipes.'); +CALL insert_responsibility('can_edit_own_comment', 'Allows users to edit their own comments.'); +CALL insert_responsibility('can_edit_any_comment', 'Grants the ability to modify any comment in the system.'); +CALL insert_responsibility('can_delete_own_comment', 'Enables users to delete their own comments.'); +CALL insert_responsibility('can_delete_any_comment', 'Grants the ability to remove any comment from the system.'); -- Ingredient management -CALL insert_responsibility( - 'can_create_ingredient', - 'Allows the addition of new ingredients to the database.' -); -CALL insert_responsibility( - 'can_edit_ingredient', - 'Grants permission to modify existing ingredient details.' -); -CALL insert_responsibility( - 'can_delete_ingredient', - 'Allows the removal of ingredients from the database.' -); +CALL insert_responsibility('can_create_ingredient', 'Allows the addition of new ingredients to the database.'); +CALL insert_responsibility('can_edit_ingredient', 'Grants permission to modify existing ingredient details.'); +CALL insert_responsibility('can_delete_ingredient', 'Allows the removal of ingredients from the database.'); -- Media management -CALL insert_responsibility( - 'can_upload_picture', - 'Enables users to upload pictures to the system.' -); -CALL insert_responsibility( - 'can_delete_picture', - 'Grants the ability to remove pictures from the system.' -); +CALL insert_responsibility('can_upload_picture', 'Enables users to upload pictures to the system.'); +CALL insert_responsibility('can_delete_picture', 'Grants the ability to remove pictures from the system.'); -- Moderation -CALL insert_responsibility( - 'can_review_flagged_content', - 'Allows reviewing and managing content flagged as inappropriate.' -); -CALL insert_responsibility( - 'can_suspend_user_account', - 'Grants the ability to temporarily suspend a user’s account.' -); -CALL insert_responsibility( - 'can_ban_user_account', - 'Enables the banning of user accounts permanently.' -); +CALL insert_responsibility('can_review_flagged_content', 'Allows reviewing and managing content flagged as inappropriate.'); +CALL insert_responsibility('can_suspend_user_account', 'Grants the ability to temporarily suspend a user’s account.'); +CALL insert_responsibility('can_ban_user_account', 'Enables the banning of user accounts permanently.'); -- Person management -CALL insert_responsibility( - 'can_manage_any_person_profile', - 'Grants access to edit profiles of any user in the system.' -); -CALL insert_responsibility( - 'can_delete_any_person_account', - 'Allows the permanent removal of any user account.' -); +CALL insert_responsibility('can_manage_any_person_profile', 'Grants access to edit profiles of any user in the system.'); +CALL insert_responsibility('can_delete_any_person_account', 'Allows the permanent removal of any user account.'); -- Recipe management -CALL insert_responsibility( - 'can_create_recipe', - 'Allows users to create and submit new recipes.' -); -CALL insert_responsibility( - 'can_edit_own_recipe', - 'Grants users the ability to edit their own recipes.' -); -CALL insert_responsibility( - 'can_edit_any_recipe', - 'Allows editing any recipe in the system.' -); -CALL insert_responsibility( - 'can_delete_own_recipe', - 'Enables users to delete their own recipes.' -); -CALL insert_responsibility( - 'can_delete_any_recipe', - 'Grants the ability to remove any recipe from the system.' -); -CALL insert_responsibility( - 'can_publish_recipe', - 'Allows the publication of recipes to make them publicly visible.' -); -CALL insert_responsibility( - 'can_review_recipe', - 'Grants permission to review recipes for approval or feedback.' -); +CALL insert_responsibility('can_create_recipe', 'Allows users to create and submit new recipes.'); +CALL insert_responsibility('can_edit_own_recipe', 'Grants users the ability to edit their own recipes.'); +CALL insert_responsibility('can_edit_any_recipe', 'Allows editing any recipe in the system.'); +CALL insert_responsibility('can_delete_own_recipe', 'Enables users to delete their own recipes.'); +CALL insert_responsibility('can_delete_any_recipe', 'Grants the ability to remove any recipe from the system.'); +CALL insert_responsibility('can_publish_recipe', 'Allows the publication of recipes to make them publicly visible.'); +CALL insert_responsibility('can_review_recipe', 'Grants permission to review recipes for approval or feedback.'); -- Tag management -CALL insert_responsibility( - 'can_create_tag', - 'Allows the creation of new tags for categorizing content.' -); -CALL insert_responsibility( - 'can_edit_tag', - 'Grants the ability to edit existing tags.' -); -CALL insert_responsibility( - 'can_delete_tag', - 'Allows the removal of tags from the database.' -); +CALL insert_responsibility('can_create_tag', 'Allows the creation of new tags for categorizing content.'); +CALL insert_responsibility('can_edit_tag', 'Grants the ability to edit existing tags.'); +CALL insert_responsibility('can_delete_tag', 'Allows the removal of tags from the database.'); -- Translation management -CALL insert_responsibility( - 'can_add_translation', - 'Enables the addition of new translations for system content.' -); -CALL insert_responsibility( - 'can_edit_translation', - 'Grants permission to modify existing translations.' -); -CALL insert_responsibility( - 'can_delete_translation', - 'Allows the deletion of translations from the database.' -); +CALL insert_responsibility('can_add_translation', 'Enables the addition of new translations for system content.'); +CALL insert_responsibility('can_edit_translation', 'Grants permission to modify existing translations.'); +CALL insert_responsibility('can_delete_translation', 'Allows the deletion of translations from the database.'); From b7e3e770f5f112dd28a3931ea528e040ea5900ce Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:24:32 -0500 Subject: [PATCH 12/20] Refactor SQL calls for recipe ingredients and translations to improve readability by consolidating statements; update SQLFluff configuration to ignore max line length --- .sqlfluff | 3 +- setup/z_mock/recipe_ingredient.sql | 8 +- setup/z_mock/recipe_translation.sql | 199 +++------------------------- 3 files changed, 23 insertions(+), 187 deletions(-) diff --git a/.sqlfluff b/.sqlfluff index 0a33ea9..9033bea 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,5 +1,4 @@ [sqlfluff] dialect = mariadb -max_line_length = 100 exlude_rules = PRS -ignore = parsing +ignore = parsing, max_line_length diff --git a/setup/z_mock/recipe_ingredient.sql b/setup/z_mock/recipe_ingredient.sql index 762aab4..90ae621 100644 --- a/setup/z_mock/recipe_ingredient.sql +++ b/setup/z_mock/recipe_ingredient.sql @@ -4,9 +4,5 @@ USE smartcooking; -- Fill the database with mock data CALL insert_recipe_ingredient(1, 1, 2, 'g'); CALL insert_recipe_ingredient_by_name(1, 'Sugar', 1, 'tsp'); -CALL insert_recipe_ingredients( - 2, '[{"ingredient_id": 1, "quantity": 2, "unit": "g"}, {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]' -); -CALL insert_recipe_ingredients_by_name( - 3, '[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"}, {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]' -); +CALL insert_recipe_ingredients(2, '[{"ingredient_id": 1, "quantity": 2, "unit": "g"}, {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]'); +CALL insert_recipe_ingredients_by_name(3, '[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"}, {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]'); diff --git a/setup/z_mock/recipe_translation.sql b/setup/z_mock/recipe_translation.sql index c6c824b..92e47f1 100644 --- a/setup/z_mock/recipe_translation.sql +++ b/setup/z_mock/recipe_translation.sql @@ -2,182 +2,23 @@ USE smartcooking; -- Fill the database with mock data -CALL insert_recipe_translation_by_iso_code( - 1, 'en', - 'Title 1', - 'Details 1', - 'Preparation 1', - 'Nutritional information 1', - 'www.video.com' -); - -CALL insert_recipe_translation_by_iso_code( - 1, 'es', - 'Título 1', - 'Detalles 1', - 'Preparación 1', - 'Información nutricional 1', - 'www.video_es.com' -); - -CALL insert_recipe_translation_by_iso_code( - 1, 'fr', - 'Titre 1', - 'Détails 1', - 'Préparation 1', - 'Informations nutritionnelles 1', - 'www.video_fr.com' -); - -CALL insert_recipe_translation_by_iso_code( - 1, 'ko', - '제목 1', - '세부 정보 1', - '준비 1', - '영양 정보 1', - 'www.video_ko.com' -); - -CALL insert_recipe_translation_by_iso_code( - 2, 'en', - 'Title 2', - 'Details 2', - 'Preparation 2', - 'Nutritional information 2', - 'www.video.com' -); - -CALL insert_recipe_translation_by_iso_code( - 2, 'es', - 'Título 2', - 'Detalles 2', - 'Preparación 2', - 'Información nutricional 2', - 'www.video_es.com' -); - -CALL insert_recipe_translation_by_iso_code( - 2, 'fr', - 'Titre 2', - 'Détails 2', - 'Préparation 2', - 'Informations nutritionnelles 2', - 'www.video_fr.com' -); - -CALL insert_recipe_translation_by_iso_code( - 2, 'ko', - '제목 2', - '세부 정보 2', - '준비 2', - '영양 정보 2', - 'www.video_ko.com' -); - -CALL insert_recipe_translation_by_iso_code( - 3, 'en', - 'Title 3', - 'Details 3', - 'Preparation 3', - 'Nutritional information 3', - 'www.video.com' -); - -CALL insert_recipe_translation_by_iso_code( - 3, 'es', - 'Título 3', - 'Detalles 3', - 'Preparación 3', - 'Información nutricional 3', - 'www.video_es.com' -); - -CALL insert_recipe_translation_by_iso_code( - 3, 'fr', - 'Titre 3', - 'Détails 3', - 'Préparation 3', - 'Informations nutritionnelles 3', - 'www.video_fr.com' -); - -CALL insert_recipe_translation_by_iso_code( - 3, 'ko', - '제목 3', - '세부 정보 3', - '준비 3', - '영양 정보 3', - 'www.video_ko.com' -); - -CALL insert_recipe_translation_by_iso_code( - 4, 'en', - 'Title 4', - 'Details 4', - 'Preparation 4', - 'Nutritional information 4', - 'www.video.com' -); - -CALL insert_recipe_translation_by_iso_code( - 4, 'es', - 'Título 4', - 'Detalles 4', - 'Preparación 4', - 'Información nutricional 4', - 'www.video_es.com' -); - -CALL insert_recipe_translation_by_iso_code( - 4, 'fr', - 'Titre 4', - 'Détails 4', - 'Préparation 4', - 'Informations nutritionnelles 4', - 'www.video_fr.com' -); - -CALL insert_recipe_translation_by_iso_code( - 4, 'ko', - '제목 4', - '세부 정보 4', - '준비 4', - '영양 정보 4', - 'www.video_ko.com' -); - -CALL insert_recipe_translation_by_iso_code( - 5, 'en', - 'Title 5', - 'Details 5', - 'Preparation 5', - 'Nutritional information 5', - 'www.video.com' -); - -CALL insert_recipe_translation_by_iso_code( - 5, 'es', - 'Título 5', - 'Detalles 5', - 'Preparación 5', - 'Información nutricional 5', - 'www.video_es.com' -); - -CALL insert_recipe_translation_by_iso_code( - 5, 'fr', - 'Titre 5', - 'Détails 5', - 'Préparation 5', - 'Informations nutritionnelles 5', - 'www.video_fr.com' -); - -CALL insert_recipe_translation_by_iso_code( - 5, 'ko', - '제목 5', - '세부 정보 5', - '준비 5', - '영양 정보 5', - 'www.video_ko.com' -); +CALL insert_recipe_translation_by_iso_code(1, 'en', 'Title 1', 'Details 1', 'Preparation 1', 'Nutritional information 1', 'www.video.com'); +CALL insert_recipe_translation_by_iso_code(1, 'es', 'Título 1', 'Detalles 1', 'Preparación 1', 'Información nutricional 1', 'www.video_es.com'); +CALL insert_recipe_translation_by_iso_code(1, 'fr', 'Titre 1', 'Détails 1', 'Préparation 1', 'Informations nutritionnelles 1', 'www.video_fr.com'); +CALL insert_recipe_translation_by_iso_code(1, 'ko', '제목 1', '세부 정보 1', '준비 1', '영양 정보 1', 'www.video_ko.com'); +CALL insert_recipe_translation_by_iso_code(2, 'en', 'Title 2', 'Details 2', 'Preparation 2', 'Nutritional information 2', 'www.video.com'); +CALL insert_recipe_translation_by_iso_code(2, 'es', 'Título 2', 'Detalles 2', 'Preparación 2', 'Información nutricional 2', 'www.video_es.com'); +CALL insert_recipe_translation_by_iso_code(2, 'fr', 'Titre 2', 'Détails 2', 'Préparation 2', 'Informations nutritionnelles 2', 'www.video_fr.com'); +CALL insert_recipe_translation_by_iso_code(2, 'ko', '제목 2', '세부 정보 2', '준비 2', '영양 정보 2', 'www.video_ko.com'); +CALL insert_recipe_translation_by_iso_code(3, 'en', 'Title 3', 'Details 3', 'Preparation 3', 'Nutritional information 3', 'www.video.com'); +CALL insert_recipe_translation_by_iso_code(3, 'es', 'Título 3', 'Detalles 3', 'Preparación 3', 'Información nutricional 3', 'www.video_es.com'); +CALL insert_recipe_translation_by_iso_code(3, 'fr', 'Titre 3', 'Détails 3', 'Préparation 3', 'Informations nutritionnelles 3', 'www.video_fr.com'); +CALL insert_recipe_translation_by_iso_code(3, 'ko', '제목 3', '세부 정보 3', '준비 3', '영양 정보 3', 'www.video_ko.com'); +CALL insert_recipe_translation_by_iso_code(4, 'en', 'Title 4', 'Details 4', 'Preparation 4', 'Nutritional information 4', 'www.video.com'); +CALL insert_recipe_translation_by_iso_code(4, 'es', 'Título 4', 'Detalles 4', 'Preparación 4', 'Información nutricional 4', 'www.video_es.com'); +CALL insert_recipe_translation_by_iso_code(4, 'fr', 'Titre 4', 'Détails 4', 'Préparation 4', 'Informations nutritionnelles 4', 'www.video_fr.com'); +CALL insert_recipe_translation_by_iso_code(4, 'ko', '제목 4', '세부 정보 4', '준비 4', '영양 정보 4', 'www.video_ko.com'); +CALL insert_recipe_translation_by_iso_code(5, 'en', 'Title 5', 'Details 5', 'Preparation 5', 'Nutritional information 5', 'www.video.com'); +CALL insert_recipe_translation_by_iso_code(5, 'es', 'Título 5', 'Detalles 5', 'Preparación 5', 'Información nutricional 5', 'www.video_es.com'); +CALL insert_recipe_translation_by_iso_code(5, 'fr', 'Titre 5', 'Détails 5', 'Préparation 5', 'Informations nutritionnelles 5', 'www.video_fr.com'); +CALL insert_recipe_translation_by_iso_code(5, 'ko', '제목 5', '세부 정보 5', '준비 5', '영양 정보 5', 'www.video_ko.com'); From 7af904e8fd196b196dad479fc41c8521cfe094c4 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:27:35 -0500 Subject: [PATCH 13/20] Update SQLFluff configuration to ignore layout long lines instead of max line length --- .sqlfluff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sqlfluff b/.sqlfluff index 9033bea..de50ebd 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,4 +1,4 @@ [sqlfluff] dialect = mariadb exlude_rules = PRS -ignore = parsing, max_line_length +ignore = parsing, layout.long_lines From c74a2e55e1c14725b40b13f211c27e54ff8ce141 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:33:18 -0500 Subject: [PATCH 14/20] Update SQLFluff configuration to ignore specific parsing rule L016 --- .sqlfluff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sqlfluff b/.sqlfluff index de50ebd..bedf688 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,4 +1,4 @@ [sqlfluff] dialect = mariadb exlude_rules = PRS -ignore = parsing, layout.long_lines +ignore = parsing, L016 From 19e711990ada25acb53f407ae41087a16351a0fb Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:36:00 -0500 Subject: [PATCH 15/20] Update SQLFluff configuration to ignore specific parsing rule LT05 --- .sqlfluff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sqlfluff b/.sqlfluff index bedf688..17e8b05 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,4 +1,4 @@ [sqlfluff] dialect = mariadb exlude_rules = PRS -ignore = parsing, L016 +ignore = parsing, LT05 From 272892af151fbb48784203104b0032a2f2740c7f Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:39:28 -0500 Subject: [PATCH 16/20] Update SQLFluff configuration to exclude rule LT05 from parsing checks --- .sqlfluff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.sqlfluff b/.sqlfluff index 17e8b05..20641b9 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,4 +1,4 @@ [sqlfluff] dialect = mariadb -exlude_rules = PRS -ignore = parsing, LT05 +exlude_rules = PRS, LT05 +ignore = parsing From da72552cb8232de584719028bce74029d0024a2b Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:44:04 -0500 Subject: [PATCH 17/20] Update SQLFluff configuration to exclude rule L032 from parsing checks --- .sqlfluff | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.sqlfluff b/.sqlfluff index 20641b9..100865d 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,4 +1,4 @@ [sqlfluff] dialect = mariadb -exlude_rules = PRS, LT05 +exlude_rules = PRS, L032 ignore = parsing From ebed5c53d08ddc2c419a9d3a036d23309da94d86 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:51:59 -0500 Subject: [PATCH 18/20] Update SQLFluff configuration to set max line length and exclude layout.spacing rule --- .sqlfluff | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.sqlfluff b/.sqlfluff index 100865d..753c540 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,4 +1,5 @@ [sqlfluff] dialect = mariadb -exlude_rules = PRS, L032 -ignore = parsing +max_line_length = 100 +exlude_rules = PRS, layout.spacing +ignore = parsing, layout.spacing From 5b33e9cacc2e3387bf4408b767ea1cf3dcd8d279 Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:54:50 -0500 Subject: [PATCH 19/20] Update SQLFluff configuration to exclude layout.long_lines rule and adjust ignored rules --- .sqlfluff | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.sqlfluff b/.sqlfluff index 753c540..20bbe62 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,5 +1,5 @@ [sqlfluff] dialect = mariadb max_line_length = 100 -exlude_rules = PRS, layout.spacing -ignore = parsing, layout.spacing +exlude_rules = PRS, layout.long_lines +ignore = parsing, layout.long_lines From fdda9994702a3dfc0ea0b6ada7a13f4c74b7a41f Mon Sep 17 00:00:00 2001 From: Vianpyro Date: Sat, 28 Dec 2024 23:57:50 -0500 Subject: [PATCH 20/20] Update SQLFluff configuration to increase max line length and refine ignored rules --- .sqlfluff | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.sqlfluff b/.sqlfluff index 20bbe62..af7730d 100644 --- a/.sqlfluff +++ b/.sqlfluff @@ -1,5 +1,5 @@ [sqlfluff] dialect = mariadb -max_line_length = 100 -exlude_rules = PRS, layout.long_lines -ignore = parsing, layout.long_lines +max_line_length = 200 +exlude_rules = PRS +ignore = parsing