Skip to content

Commit

Permalink
Computers are hard
Browse files Browse the repository at this point in the history
  • Loading branch information
stephenswat committed Feb 7, 2024
1 parent e7a9a0b commit f3df5c2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
3 changes: 3 additions & 0 deletions backend/abyssal_modules/models/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 7 additions & 8 deletions backend/abyssal_modules/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit f3df5c2

Please sign in to comment.