first commit
This commit is contained in:
368
calorie_tracker_app/seed_data.py
Normal file
368
calorie_tracker_app/seed_data.py
Normal file
@@ -0,0 +1,368 @@
|
||||
from models import FoodItem, db
|
||||
|
||||
def seed_filipino_foods():
|
||||
"""Populate database with common Filipino foods"""
|
||||
|
||||
filipino_foods = [
|
||||
# Rice (Kanin)
|
||||
{
|
||||
'name': 'White Rice',
|
||||
'name_tagalog': 'Kanin',
|
||||
'category': 'kanin',
|
||||
'calories': 206,
|
||||
'protein_g': 4.3,
|
||||
'carbs_g': 45,
|
||||
'fat_g': 0.4,
|
||||
'serving_description': '1 cup cooked',
|
||||
'serving_size_g': 158
|
||||
},
|
||||
{
|
||||
'name': 'Fried Rice',
|
||||
'name_tagalog': 'Sinangag',
|
||||
'category': 'kanin',
|
||||
'calories': 280,
|
||||
'protein_g': 5,
|
||||
'carbs_g': 42,
|
||||
'fat_g': 10,
|
||||
'serving_description': '1 cup',
|
||||
'serving_size_g': 170
|
||||
},
|
||||
|
||||
# Main Dishes (Ulam)
|
||||
{
|
||||
'name': 'Chicken Adobo',
|
||||
'name_tagalog': 'Adobong Manok',
|
||||
'category': 'ulam',
|
||||
'calories': 350,
|
||||
'protein_g': 35,
|
||||
'carbs_g': 5,
|
||||
'fat_g': 20,
|
||||
'serving_description': '1 serving (2 pieces)',
|
||||
'serving_size_g': 200
|
||||
},
|
||||
{
|
||||
'name': 'Pork Sinigang',
|
||||
'name_tagalog': 'Sinigang na Baboy',
|
||||
'category': 'sabaw',
|
||||
'calories': 280,
|
||||
'protein_g': 25,
|
||||
'carbs_g': 10,
|
||||
'fat_g': 15,
|
||||
'serving_description': '1 bowl',
|
||||
'serving_size_g': 350
|
||||
},
|
||||
{
|
||||
'name': 'Chicken Tinola',
|
||||
'name_tagalog': 'Tinolang Manok',
|
||||
'category': 'sabaw',
|
||||
'calories': 200,
|
||||
'protein_g': 28,
|
||||
'carbs_g': 8,
|
||||
'fat_g': 6,
|
||||
'serving_description': '1 bowl',
|
||||
'serving_size_g': 350
|
||||
},
|
||||
{
|
||||
'name': 'Bicol Express',
|
||||
'name_tagalog': 'Bicol Express',
|
||||
'category': 'ulam',
|
||||
'calories': 400,
|
||||
'protein_g': 20,
|
||||
'carbs_g': 10,
|
||||
'fat_g': 32,
|
||||
'serving_description': '1 serving',
|
||||
'serving_size_g': 200
|
||||
},
|
||||
{
|
||||
'name': 'Pork Sisig',
|
||||
'name_tagalog': 'Sisig',
|
||||
'category': 'ulam',
|
||||
'calories': 450,
|
||||
'protein_g': 25,
|
||||
'carbs_g': 8,
|
||||
'fat_g': 35,
|
||||
'serving_description': '1 serving',
|
||||
'serving_size_g': 180
|
||||
},
|
||||
{
|
||||
'name': 'Menudo',
|
||||
'name_tagalog': 'Menudo',
|
||||
'category': 'ulam',
|
||||
'calories': 320,
|
||||
'protein_g': 22,
|
||||
'carbs_g': 12,
|
||||
'fat_g': 20,
|
||||
'serving_description': '1 serving',
|
||||
'serving_size_g': 200
|
||||
},
|
||||
{
|
||||
'name': 'Kare-Kare',
|
||||
'name_tagalog': 'Kare-Kare',
|
||||
'category': 'ulam',
|
||||
'calories': 380,
|
||||
'protein_g': 24,
|
||||
'carbs_g': 18,
|
||||
'fat_g': 25,
|
||||
'serving_description': '1 serving',
|
||||
'serving_size_g': 250
|
||||
},
|
||||
{
|
||||
'name': 'Lechon Kawali',
|
||||
'name_tagalog': 'Lechon Kawali',
|
||||
'category': 'ulam',
|
||||
'calories': 500,
|
||||
'protein_g': 30,
|
||||
'carbs_g': 2,
|
||||
'fat_g': 42,
|
||||
'serving_description': '1 serving',
|
||||
'serving_size_g': 150
|
||||
},
|
||||
{
|
||||
'name': 'Pork Nilaga',
|
||||
'name_tagalog': 'Nilagang Baboy',
|
||||
'category': 'sabaw',
|
||||
'calories': 280,
|
||||
'protein_g': 28,
|
||||
'carbs_g': 12,
|
||||
'fat_g': 14,
|
||||
'serving_description': '1 bowl',
|
||||
'serving_size_g': 350
|
||||
},
|
||||
{
|
||||
'name': 'Beef Bulalo',
|
||||
'name_tagalog': 'Bulalo',
|
||||
'category': 'sabaw',
|
||||
'calories': 350,
|
||||
'protein_g': 32,
|
||||
'carbs_g': 8,
|
||||
'fat_g': 22,
|
||||
'serving_description': '1 bowl',
|
||||
'serving_size_g': 400
|
||||
},
|
||||
|
||||
# Vegetables (Gulay)
|
||||
{
|
||||
'name': 'Pinakbet',
|
||||
'name_tagalog': 'Pinakbet',
|
||||
'category': 'gulay',
|
||||
'calories': 150,
|
||||
'protein_g': 5,
|
||||
'carbs_g': 20,
|
||||
'fat_g': 6,
|
||||
'serving_description': '1 cup',
|
||||
'serving_size_g': 200
|
||||
},
|
||||
{
|
||||
'name': 'Laing',
|
||||
'name_tagalog': 'Laing',
|
||||
'category': 'gulay',
|
||||
'calories': 180,
|
||||
'protein_g': 6,
|
||||
'carbs_g': 15,
|
||||
'fat_g': 12,
|
||||
'serving_description': '1 cup',
|
||||
'serving_size_g': 180
|
||||
},
|
||||
{
|
||||
'name': 'Ginisang Monggo',
|
||||
'name_tagalog': 'Ginisang Monggo',
|
||||
'category': 'gulay',
|
||||
'calories': 200,
|
||||
'protein_g': 12,
|
||||
'carbs_g': 30,
|
||||
'fat_g': 4,
|
||||
'serving_description': '1 cup',
|
||||
'serving_size_g': 220
|
||||
},
|
||||
|
||||
# Breakfast (Almusal)
|
||||
{
|
||||
'name': 'Beef Tapa with Rice and Egg',
|
||||
'name_tagalog': 'Tapsilog',
|
||||
'category': 'almusal',
|
||||
'calories': 650,
|
||||
'protein_g': 45,
|
||||
'carbs_g': 60,
|
||||
'fat_g': 25,
|
||||
'serving_description': '1 plate',
|
||||
'serving_size_g': 400
|
||||
},
|
||||
{
|
||||
'name': 'Longganisa with Rice and Egg',
|
||||
'name_tagalog': 'Longsilog',
|
||||
'category': 'almusal',
|
||||
'calories': 700,
|
||||
'protein_g': 38,
|
||||
'carbs_g': 65,
|
||||
'fat_g': 32,
|
||||
'serving_description': '1 plate',
|
||||
'serving_size_g': 420
|
||||
},
|
||||
{
|
||||
'name': 'Tocino with Rice and Egg',
|
||||
'name_tagalog': 'Tocilog',
|
||||
'category': 'almusal',
|
||||
'calories': 680,
|
||||
'protein_g': 42,
|
||||
'carbs_g': 62,
|
||||
'fat_g': 28,
|
||||
'serving_description': '1 plate',
|
||||
'serving_size_g': 400
|
||||
},
|
||||
{
|
||||
'name': 'Fried Egg',
|
||||
'name_tagalog': 'Pritong Itlog',
|
||||
'category': 'almusal',
|
||||
'calories': 90,
|
||||
'protein_g': 6,
|
||||
'carbs_g': 1,
|
||||
'fat_g': 7,
|
||||
'serving_description': '1 egg',
|
||||
'serving_size_g': 50
|
||||
},
|
||||
|
||||
# Snacks (Meryenda)
|
||||
{
|
||||
'name': 'Pandesal',
|
||||
'name_tagalog': 'Pandesal',
|
||||
'category': 'meryenda',
|
||||
'calories': 120,
|
||||
'protein_g': 3,
|
||||
'carbs_g': 22,
|
||||
'fat_g': 2,
|
||||
'serving_description': '1 piece',
|
||||
'serving_size_g': 40
|
||||
},
|
||||
{
|
||||
'name': 'Turon',
|
||||
'name_tagalog': 'Turon',
|
||||
'category': 'meryenda',
|
||||
'calories': 180,
|
||||
'protein_g': 2,
|
||||
'carbs_g': 35,
|
||||
'fat_g': 5,
|
||||
'serving_description': '1 piece',
|
||||
'serving_size_g': 80
|
||||
},
|
||||
{
|
||||
'name': 'Bibingka',
|
||||
'name_tagalog': 'Bibingka',
|
||||
'category': 'meryenda',
|
||||
'calories': 220,
|
||||
'protein_g': 5,
|
||||
'carbs_g': 38,
|
||||
'fat_g': 6,
|
||||
'serving_description': '1 piece',
|
||||
'serving_size_g': 100
|
||||
},
|
||||
{
|
||||
'name': 'Puto',
|
||||
'name_tagalog': 'Puto',
|
||||
'category': 'meryenda',
|
||||
'calories': 90,
|
||||
'protein_g': 2,
|
||||
'carbs_g': 18,
|
||||
'fat_g': 1,
|
||||
'serving_description': '1 piece',
|
||||
'serving_size_g': 40
|
||||
},
|
||||
{
|
||||
'name': 'Lumpia',
|
||||
'name_tagalog': 'Lumpia',
|
||||
'category': 'meryenda',
|
||||
'calories': 100,
|
||||
'protein_g': 4,
|
||||
'carbs_g': 10,
|
||||
'fat_g': 5,
|
||||
'serving_description': '1 piece',
|
||||
'serving_size_g': 50
|
||||
},
|
||||
{
|
||||
'name': 'Banana Cue',
|
||||
'name_tagalog': 'Banana Cue',
|
||||
'category': 'meryenda',
|
||||
'calories': 150,
|
||||
'protein_g': 1,
|
||||
'carbs_g': 32,
|
||||
'fat_g': 4,
|
||||
'serving_description': '1 piece',
|
||||
'serving_size_g': 100
|
||||
},
|
||||
|
||||
# Proteins
|
||||
{
|
||||
'name': 'Grilled Tilapia',
|
||||
'name_tagalog': 'Inihaw na Tilapia',
|
||||
'category': 'ulam',
|
||||
'calories': 180,
|
||||
'protein_g': 32,
|
||||
'carbs_g': 0,
|
||||
'fat_g': 5,
|
||||
'serving_description': '1 whole fish',
|
||||
'serving_size_g': 150
|
||||
},
|
||||
{
|
||||
'name': 'Grilled Chicken',
|
||||
'name_tagalog': 'Inihaw na Manok',
|
||||
'category': 'ulam',
|
||||
'calories': 280,
|
||||
'protein_g': 40,
|
||||
'carbs_g': 0,
|
||||
'fat_g': 13,
|
||||
'serving_description': '1 breast',
|
||||
'serving_size_g': 150
|
||||
},
|
||||
{
|
||||
'name': 'Fried Bangus',
|
||||
'name_tagalog': 'Pritong Bangus',
|
||||
'category': 'ulam',
|
||||
'calories': 220,
|
||||
'protein_g': 28,
|
||||
'carbs_g': 0,
|
||||
'fat_g': 12,
|
||||
'serving_description': '1 piece',
|
||||
'serving_size_g': 120
|
||||
}
|
||||
]
|
||||
|
||||
added_count = 0
|
||||
|
||||
for food_data in filipino_foods:
|
||||
# Check if already exists
|
||||
existing = FoodItem.query.filter_by(
|
||||
name=food_data['name'],
|
||||
is_filipino=True
|
||||
).first()
|
||||
|
||||
if not existing:
|
||||
food = FoodItem(
|
||||
name=food_data['name'],
|
||||
name_tagalog=food_data.get('name_tagalog'),
|
||||
category=food_data['category'],
|
||||
calories=food_data['calories'],
|
||||
protein_g=food_data['protein_g'],
|
||||
carbs_g=food_data['carbs_g'],
|
||||
fat_g=food_data['fat_g'],
|
||||
fiber_g=food_data.get('fiber_g', 0),
|
||||
sugar_g=food_data.get('sugar_g', 0),
|
||||
sodium_mg=food_data.get('sodium_mg', 0),
|
||||
serving_size_g=food_data['serving_size_g'],
|
||||
serving_description=food_data['serving_description'],
|
||||
source='filipino',
|
||||
is_filipino=True
|
||||
)
|
||||
db.session.add(food)
|
||||
added_count += 1
|
||||
|
||||
try:
|
||||
db.session.commit()
|
||||
print(f"Successfully added {added_count} Filipino foods to the database!")
|
||||
except Exception as e:
|
||||
db.session.rollback()
|
||||
print(f"Error seeding Filipino foods: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
from app import app, db
|
||||
|
||||
with app.app_context():
|
||||
seed_filipino_foods()
|
||||
Reference in New Issue
Block a user