diff --git a/backend/abyssal_modules/models/attributes.py b/backend/abyssal_modules/models/attributes.py index e20bb50..9d0fe7d 100644 --- a/backend/abyssal_modules/models/attributes.py +++ b/backend/abyssal_modules/models/attributes.py @@ -110,6 +110,9 @@ class ModuleAttribute(models.Model): value = models.FloatField(db_index=True) + class Meta: + indexes = [models.Index(fields=["module", "attribute"])] + class TypeAttribute(models.Model): type = models.ForeignKey("ModuleType", models.CASCADE) diff --git a/backend/abyssal_modules/views.py b/backend/abyssal_modules/views.py index 9fefb86..b40a8f6 100644 --- a/backend/abyssal_modules/views.py +++ b/backend/abyssal_modules/views.py @@ -158,17 +158,16 @@ def get(self, request, type_id): res = {} for k in attributes: - if k.display: - qs = ModuleAttribute.objects.filter( - module__type=module_type, attribute=k.attribute - ) + qs = ModuleAttribute.objects.filter( + module__type=module_type, attribute=k.attribute + ) - d1 = qs.order_by("value")[:10] - d2 = qs.order_by("-value")[:10] + d1 = qs.order_by("value")[:10] + d2 = qs.order_by("-value")[:10] - hig = correct_high_is_good(k.high_is_good, k.id) + hig = correct_high_is_good(k.high_is_good, k.id) - res[k.id] = (k.attribute, d2 if hig else d1, d1 if hig else d2) + res[k.id] = (k.attribute, d2 if hig else d1, d1 if hig else d2) cache.set(key, res, 60 * 120)