Self hosted FLOSS fitness/workout, nutrition and weight tracker
Add indices for the ingredient model
Roland Geider549113305077
diff --git a/wger/nutrition/migrations/0030_add_indices.py b/wger/nutrition/migrations/0030_add_indices.pynew file mode 100644index 000000000..b1fa74bef--- /dev/null+++ b/wger/nutrition/migrations/0030_add_indices.py@@ -0,0 +1,64 @@+# Generated by Django 5.2.12 on 2026-03-26 22:47++import datetime+from django.db import migrations, models+++class Migration(migrations.Migration):+ dependencies = [+ ('core', '0021_add_unit_type_to_repetitionunit'),+ ('nutrition', '0029_ingredient_nutriscore'),+ ]++ operations = [+ migrations.AlterModelOptions(+ name='nutritionplan',+ options={'ordering': ['-start']},+ ),+ migrations.AlterField(+ model_name='nutritionplan',+ name='start',+ field=models.DateField(+ blank=True,+ default=datetime.date.today,+ verbose_name='Start date',+ ),+ ),+ migrations.AddIndex(+ model_name='ingredient',+ index=models.Index(+ fields=['last_update'],+ name='idx_ingredient_last_update',+ ),+ ),+ migrations.AddIndex(+ model_name='ingredient',+ index=models.Index(+ fields=['last_imported'],+ name='idx_ingredient_last_imported',+ ),+ ),+ migrations.AddIndex(+ model_name='ingredient',+ index=models.Index(+ condition=models.Q(('is_vegan', True)),+ fields=['is_vegan'],+ name='idx_ingredient_vegan',+ ),+ ),+ migrations.AddIndex(+ model_name='ingredient',+ index=models.Index(+ condition=models.Q(('is_vegetarian', True)),+ fields=['is_vegetarian'],+ name='idx_ingredient_vegetarian',+ ),+ ),+ migrations.AddIndex(+ model_name='ingredient',+ index=models.Index(+ fields=['nutriscore'],+ name='idx_ingredient_nutriscore',+ ),+ ),+ ]diff --git a/wger/nutrition/models/ingredient.py b/wger/nutrition/models/ingredient.pyindex 9223ed45e..b22a5341e 100644--- a/wger/nutrition/models/ingredient.py+++ b/wger/nutrition/models/ingredient.py@@ -70,6 +70,39 @@ class Ingredient(AbstractLicenseModel, models.Model):An ingredient, with some approximate nutrition values"""+ class Meta:+ ordering = [+ 'name',+ ]+ indexes = (+ GinIndex(+ fields=['name'],+ name='nutrition_i_search__f274b7_gin',+ ),+ models.Index(+ fields=['last_update'],+ name='idx_ingredient_last_update',+ ),+ models.Index(+ fields=['last_imported'],+ name='idx_ingredient_last_imported',+ ),+ models.Index(+ fields=['is_vegan'],+ name='idx_ingredient_vegan',+ condition=models.Q(is_vegan=True),+ ),+ models.Index(+ fields=['is_vegetarian'],+ name='idx_ingredient_vegetarian',+ condition=models.Q(is_vegetarian=True),+ ),+ models.Index(+ fields=['nutriscore'],+ name='idx_ingredient_nutriscore',+ ),+ )+ENERGY_APPROXIMATION = 15"""How much the calculated energy from protein, etc. can deviate from the@@ -294,13 +327,6 @@ class Ingredient(AbstractLicenseModel, models.Model):)"""Nutri-Score from Open Food Facts"""- # Metaclass to set some other properties- class Meta:- ordering = [- 'name',- ]- indexes = (GinIndex(fields=['name']),)-## Django methods#