Skip to content

Commit a56c804

Browse files
author
Vianpyro
committed
Refactor mock data insertion for recipe ingredients and translations for improved readability
1 parent d517132 commit a56c804

File tree

3 files changed

+322
-55
lines changed

3 files changed

+322
-55
lines changed

setup/responsibility.sql

Lines changed: 133 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,154 @@
22
USE smartcooking;
33

44
-- Administrative
5-
CALL insert_responsibility('can_manage_roles', 'Allows the ability to create, edit, or delete user roles and their associated permissions.');
6-
CALL insert_responsibility('can_view_audit_log', 'Allows access to view detailed records of database activities and changes for auditing purposes.');
5+
CALL insert_responsibility(
6+
'can_manage_roles',
7+
'Allows the ability to create, edit, or delete user roles and their associated permissions.'
8+
);
9+
CALL insert_responsibility(
10+
'can_view_audit_log',
11+
'Allows access to view detailed records of database activities' ||
12+
' and changes for auditing purposes.'
13+
);
714

815
-- Category management
9-
CALL insert_responsibility('can_create_category', 'Grants the ability to create new categories for organizing content.');
10-
CALL insert_responsibility('can_edit_category', 'Allows editing existing categories to update their details.');
11-
CALL insert_responsibility('can_delete_category', 'Grants permission to remove categories from the database.');
16+
CALL insert_responsibility(
17+
'can_create_category',
18+
'Grants the ability to create new categories for organizing content.'
19+
);
20+
CALL insert_responsibility(
21+
'can_edit_category',
22+
'Allows editing existing categories to update their details.'
23+
);
24+
CALL insert_responsibility(
25+
'can_delete_category',
26+
'Grants permission to remove categories from the database.'
27+
);
1228

1329
-- Comment management
14-
CALL insert_responsibility('can_comment_on_recipe', 'Enables the user to post comments on recipes.');
15-
CALL insert_responsibility('can_edit_own_comment', 'Allows users to edit their own comments.');
16-
CALL insert_responsibility('can_edit_any_comment', 'Grants the ability to modify any comment in the system.');
17-
CALL insert_responsibility('can_delete_own_comment', 'Enables users to delete their own comments.');
18-
CALL insert_responsibility('can_delete_any_comment', 'Grants the ability to remove any comment from the system.');
30+
CALL insert_responsibility(
31+
'can_comment_on_recipe',
32+
'Enables the user to post comments on recipes.'
33+
);
34+
CALL insert_responsibility(
35+
'can_edit_own_comment',
36+
'Allows users to edit their own comments.'
37+
);
38+
CALL insert_responsibility(
39+
'can_edit_any_comment',
40+
'Grants the ability to modify any comment in the system.'
41+
);
42+
CALL insert_responsibility(
43+
'can_delete_own_comment',
44+
'Enables users to delete their own comments.'
45+
);
46+
CALL insert_responsibility(
47+
'can_delete_any_comment',
48+
'Grants the ability to remove any comment from the system.'
49+
);
1950

2051
-- Ingredient management
21-
CALL insert_responsibility('can_create_ingredient', 'Allows the addition of new ingredients to the database.');
22-
CALL insert_responsibility('can_edit_ingredient', 'Grants permission to modify existing ingredient details.');
23-
CALL insert_responsibility('can_delete_ingredient', 'Allows the removal of ingredients from the database.');
52+
CALL insert_responsibility(
53+
'can_create_ingredient',
54+
'Allows the addition of new ingredients to the database.'
55+
);
56+
CALL insert_responsibility(
57+
'can_edit_ingredient',
58+
'Grants permission to modify existing ingredient details.'
59+
);
60+
CALL insert_responsibility(
61+
'can_delete_ingredient',
62+
'Allows the removal of ingredients from the database.'
63+
);
2464

2565
-- Media management
26-
CALL insert_responsibility('can_upload_picture', 'Enables users to upload pictures to the system.');
27-
CALL insert_responsibility('can_delete_picture', 'Grants the ability to remove pictures from the system.');
66+
CALL insert_responsibility(
67+
'can_upload_picture',
68+
'Enables users to upload pictures to the system.'
69+
);
70+
CALL insert_responsibility(
71+
'can_delete_picture',
72+
'Grants the ability to remove pictures from the system.'
73+
);
2874

2975
-- Moderation
30-
CALL insert_responsibility('can_review_flagged_content', 'Allows reviewing and managing content flagged as inappropriate.');
31-
CALL insert_responsibility('can_suspend_user_account', 'Grants the ability to temporarily suspend a user’s account.');
32-
CALL insert_responsibility('can_ban_user_account', 'Enables the banning of user accounts permanently.');
76+
CALL insert_responsibility(
77+
'can_review_flagged_content',
78+
'Allows reviewing and managing content flagged as inappropriate.'
79+
);
80+
CALL insert_responsibility(
81+
'can_suspend_user_account',
82+
'Grants the ability to temporarily suspend a user’s account.'
83+
);
84+
CALL insert_responsibility(
85+
'can_ban_user_account',
86+
'Enables the banning of user accounts permanently.'
87+
);
3388

3489
-- Person management
35-
CALL insert_responsibility('can_manage_any_person_profile', 'Grants access to edit profiles of any user in the system.');
36-
CALL insert_responsibility('can_delete_any_person_account', 'Allows the permanent removal of any user account.');
90+
CALL insert_responsibility(
91+
'can_manage_any_person_profile',
92+
'Grants access to edit profiles of any user in the system.'
93+
);
94+
CALL insert_responsibility(
95+
'can_delete_any_person_account',
96+
'Allows the permanent removal of any user account.'
97+
);
3798

3899
-- Recipe management
39-
CALL insert_responsibility('can_create_recipe', 'Allows users to create and submit new recipes.');
40-
CALL insert_responsibility('can_edit_own_recipe', 'Grants users the ability to edit their own recipes.');
41-
CALL insert_responsibility('can_edit_any_recipe', 'Allows editing any recipe in the system.');
42-
CALL insert_responsibility('can_delete_own_recipe', 'Enables users to delete their own recipes.');
43-
CALL insert_responsibility('can_delete_any_recipe', 'Grants the ability to remove any recipe from the system.');
44-
CALL insert_responsibility('can_publish_recipe', 'Allows the publication of recipes to make them publicly visible.');
45-
CALL insert_responsibility('can_review_recipe', 'Grants permission to review recipes for approval or feedback.');
100+
CALL insert_responsibility(
101+
'can_create_recipe',
102+
'Allows users to create and submit new recipes.'
103+
);
104+
CALL insert_responsibility(
105+
'can_edit_own_recipe',
106+
'Grants users the ability to edit their own recipes.'
107+
);
108+
CALL insert_responsibility(
109+
'can_edit_any_recipe',
110+
'Allows editing any recipe in the system.'
111+
);
112+
CALL insert_responsibility(
113+
'can_delete_own_recipe',
114+
'Enables users to delete their own recipes.'
115+
);
116+
CALL insert_responsibility(
117+
'can_delete_any_recipe',
118+
'Grants the ability to remove any recipe from the system.'
119+
);
120+
CALL insert_responsibility(
121+
'can_publish_recipe',
122+
'Allows the publication of recipes to make them publicly visible.'
123+
);
124+
CALL insert_responsibility(
125+
'can_review_recipe',
126+
'Grants permission to review recipes for approval or feedback.'
127+
);
46128

47129
-- Tag management
48-
CALL insert_responsibility('can_create_tag', 'Allows the creation of new tags for categorizing content.');
49-
CALL insert_responsibility('can_edit_tag', 'Grants the ability to edit existing tags.');
50-
CALL insert_responsibility('can_delete_tag', 'Allows the removal of tags from the database.');
130+
CALL insert_responsibility(
131+
'can_create_tag',
132+
'Allows the creation of new tags for categorizing content.'
133+
);
134+
CALL insert_responsibility(
135+
'can_edit_tag',
136+
'Grants the ability to edit existing tags.'
137+
);
138+
CALL insert_responsibility(
139+
'can_delete_tag',
140+
'Allows the removal of tags from the database.'
141+
);
51142

52143
-- Translation management
53-
CALL insert_responsibility('can_add_translation', 'Enables the addition of new translations for system content.');
54-
CALL insert_responsibility('can_edit_translation', 'Grants permission to modify existing translations.');
55-
CALL insert_responsibility('can_delete_translation', 'Allows the deletion of translations from the database.');
144+
CALL insert_responsibility(
145+
'can_add_translation',
146+
'Enables the addition of new translations for system content.'
147+
);
148+
CALL insert_responsibility(
149+
'can_edit_translation',
150+
'Grants permission to modify existing translations.'
151+
);
152+
CALL insert_responsibility(
153+
'can_delete_translation',
154+
'Allows the deletion of translations from the database.'
155+
);

setup/z_mock/recipe_ingredient.sql

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,13 @@ USE smartcooking;
44
-- Fill the database with mock data
55
CALL insert_recipe_ingredient(1, 1, 2, 'g');
66
CALL insert_recipe_ingredient_by_name(1, 'Sugar', 1, 'tsp');
7-
CALL insert_recipe_ingredients(2, '[{"ingredient_id": 1, "quantity": 2, "unit": "g"}, {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]');
8-
CALL insert_recipe_ingredients_by_name(3, '[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"}, {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]');
7+
CALL insert_recipe_ingredients(
8+
2,
9+
'[{"ingredient_id": 1, "quantity": 2, "unit": "g"},' ||
10+
' {"ingredient_id": 2, "quantity": 1, "unit": "tsp"}]'
11+
);
12+
CALL insert_recipe_ingredients_by_name(
13+
3,
14+
'[{"ingredient_name": "Salt", "quantity": 2, "unit": "g"},' ||
15+
' {"ingredient_name": "Pepper", "quantity": 1, "unit": "tsp"}]'
16+
);

0 commit comments

Comments
 (0)