Merge pull request 'ordered from update list of devices' (#55) from timestamp into main

Reviewed-on: #55
This commit is contained in:
cayop 2025-02-20 17:43:55 +00:00
commit 29f08a633b
2 changed files with 22 additions and 2 deletions

View file

@ -52,8 +52,18 @@ class LotDashboardView(InventaryMixin, DetailsMixin):
"device_id", flat=True
).distinct()
chids_page = chids[offset:offset+limit]
return [Device(id=x) for x in chids_page], chids.count()
props = SystemProperty.objects.filter(
owner=self.request.user.institution,
value__in=chids
).order_by("-created")
chids_ordered = []
for x in props:
if x.value not in chids_ordered:
chids_ordered.append(x.value)
chids_page = chids_ordered[offset:offset+limit]
return [Device(id=x) for x in chids_page], len(chids_ordered)
class SearchView(InventaryMixin):

View file

@ -143,6 +143,7 @@ class Device:
SELECT
t1.value,
t1.key,
t1.created,
ROW_NUMBER() OVER (
PARTITION BY t1.uuid
ORDER BY
@ -162,6 +163,7 @@ class Device:
RankedProperties
WHERE
row_num = 1
ORDER BY created DESC
""".format(
institution=institution.id,
algorithm=institution.algorithm,
@ -188,6 +190,7 @@ class Device:
SELECT
t1.value,
t1.key,
t1.created,
ROW_NUMBER() OVER (
PARTITION BY t1.uuid
ORDER BY
@ -208,6 +211,7 @@ class Device:
RankedProperties
WHERE
row_num = 1
ORDER BY created DESC
""".format(
institution=institution.id,
algorithm=institution.algorithm
@ -225,6 +229,7 @@ class Device:
SELECT
t1.value,
t1.key,
t1.created,
ROW_NUMBER() OVER (
PARTITION BY t1.uuid
ORDER BY
@ -246,6 +251,7 @@ class Device:
RankedProperties
WHERE
row_num = 1
ORDER BY created DESC
""".format(
institution=institution.id,
algorithm=institution.algorithm
@ -272,6 +278,7 @@ class Device:
SELECT
t1.value,
t1.key,
t1.created,
ROW_NUMBER() OVER (
PARTITION BY t1.uuid
ORDER BY
@ -293,6 +300,7 @@ class Device:
RankedProperties
WHERE
row_num = 1
ORDER BY created DESC
""".format(
institution=institution.id,
algorithm=institution.algorithm
@ -308,6 +316,7 @@ class Device:
SELECT
t1.value,
t1.key,
t1.created,
ROW_NUMBER() OVER (
PARTITION BY t1.uuid
ORDER BY
@ -328,6 +337,7 @@ class Device:
RankedProperties
WHERE
row_num = 1;
ORDER BY created DESC
""".format(
uuid=uuid.replace("-", ""),
institution=institution.id,