ordered from update list of devices
This commit is contained in:
parent
885ad9a702
commit
868aabc666
|
@ -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):
|
||||
|
|
|
@ -144,6 +144,7 @@ class Device:
|
|||
SELECT
|
||||
t1.value,
|
||||
t1.key,
|
||||
t1.created,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY t1.uuid
|
||||
ORDER BY
|
||||
|
@ -163,6 +164,7 @@ class Device:
|
|||
RankedProperties
|
||||
WHERE
|
||||
row_num = 1
|
||||
ORDER BY created DESC
|
||||
""".format(
|
||||
institution=institution.id,
|
||||
algorithm=institution.algorithm,
|
||||
|
@ -189,6 +191,7 @@ class Device:
|
|||
SELECT
|
||||
t1.value,
|
||||
t1.key,
|
||||
t1.created,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY t1.uuid
|
||||
ORDER BY
|
||||
|
@ -209,6 +212,7 @@ class Device:
|
|||
RankedProperties
|
||||
WHERE
|
||||
row_num = 1
|
||||
ORDER BY created DESC
|
||||
""".format(
|
||||
institution=institution.id,
|
||||
algorithm=institution.algorithm
|
||||
|
@ -226,6 +230,7 @@ class Device:
|
|||
SELECT
|
||||
t1.value,
|
||||
t1.key,
|
||||
t1.created,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY t1.uuid
|
||||
ORDER BY
|
||||
|
@ -247,6 +252,7 @@ class Device:
|
|||
RankedProperties
|
||||
WHERE
|
||||
row_num = 1
|
||||
ORDER BY created DESC
|
||||
""".format(
|
||||
institution=institution.id,
|
||||
algorithm=institution.algorithm
|
||||
|
@ -273,6 +279,7 @@ class Device:
|
|||
SELECT
|
||||
t1.value,
|
||||
t1.key,
|
||||
t1.created,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY t1.uuid
|
||||
ORDER BY
|
||||
|
@ -294,6 +301,7 @@ class Device:
|
|||
RankedProperties
|
||||
WHERE
|
||||
row_num = 1
|
||||
ORDER BY created DESC
|
||||
""".format(
|
||||
institution=institution.id,
|
||||
algorithm=institution.algorithm
|
||||
|
@ -309,6 +317,7 @@ class Device:
|
|||
SELECT
|
||||
t1.value,
|
||||
t1.key,
|
||||
t1.created,
|
||||
ROW_NUMBER() OVER (
|
||||
PARTITION BY t1.uuid
|
||||
ORDER BY
|
||||
|
@ -329,6 +338,7 @@ class Device:
|
|||
RankedProperties
|
||||
WHERE
|
||||
row_num = 1;
|
||||
ORDER BY created DESC
|
||||
""".format(
|
||||
uuid=uuid.replace("-", ""),
|
||||
institution=institution.id,
|
||||
|
|
Loading…
Reference in a new issue