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
|
"device_id", flat=True
|
||||||
).distinct()
|
).distinct()
|
||||||
|
|
||||||
chids_page = chids[offset:offset+limit]
|
props = SystemProperty.objects.filter(
|
||||||
return [Device(id=x) for x in chids_page], chids.count()
|
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):
|
class SearchView(InventaryMixin):
|
||||||
|
|
|
@ -144,6 +144,7 @@ class Device:
|
||||||
SELECT
|
SELECT
|
||||||
t1.value,
|
t1.value,
|
||||||
t1.key,
|
t1.key,
|
||||||
|
t1.created,
|
||||||
ROW_NUMBER() OVER (
|
ROW_NUMBER() OVER (
|
||||||
PARTITION BY t1.uuid
|
PARTITION BY t1.uuid
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -163,6 +164,7 @@ class Device:
|
||||||
RankedProperties
|
RankedProperties
|
||||||
WHERE
|
WHERE
|
||||||
row_num = 1
|
row_num = 1
|
||||||
|
ORDER BY created DESC
|
||||||
""".format(
|
""".format(
|
||||||
institution=institution.id,
|
institution=institution.id,
|
||||||
algorithm=institution.algorithm,
|
algorithm=institution.algorithm,
|
||||||
|
@ -189,6 +191,7 @@ class Device:
|
||||||
SELECT
|
SELECT
|
||||||
t1.value,
|
t1.value,
|
||||||
t1.key,
|
t1.key,
|
||||||
|
t1.created,
|
||||||
ROW_NUMBER() OVER (
|
ROW_NUMBER() OVER (
|
||||||
PARTITION BY t1.uuid
|
PARTITION BY t1.uuid
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -209,6 +212,7 @@ class Device:
|
||||||
RankedProperties
|
RankedProperties
|
||||||
WHERE
|
WHERE
|
||||||
row_num = 1
|
row_num = 1
|
||||||
|
ORDER BY created DESC
|
||||||
""".format(
|
""".format(
|
||||||
institution=institution.id,
|
institution=institution.id,
|
||||||
algorithm=institution.algorithm
|
algorithm=institution.algorithm
|
||||||
|
@ -226,6 +230,7 @@ class Device:
|
||||||
SELECT
|
SELECT
|
||||||
t1.value,
|
t1.value,
|
||||||
t1.key,
|
t1.key,
|
||||||
|
t1.created,
|
||||||
ROW_NUMBER() OVER (
|
ROW_NUMBER() OVER (
|
||||||
PARTITION BY t1.uuid
|
PARTITION BY t1.uuid
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -247,6 +252,7 @@ class Device:
|
||||||
RankedProperties
|
RankedProperties
|
||||||
WHERE
|
WHERE
|
||||||
row_num = 1
|
row_num = 1
|
||||||
|
ORDER BY created DESC
|
||||||
""".format(
|
""".format(
|
||||||
institution=institution.id,
|
institution=institution.id,
|
||||||
algorithm=institution.algorithm
|
algorithm=institution.algorithm
|
||||||
|
@ -273,6 +279,7 @@ class Device:
|
||||||
SELECT
|
SELECT
|
||||||
t1.value,
|
t1.value,
|
||||||
t1.key,
|
t1.key,
|
||||||
|
t1.created,
|
||||||
ROW_NUMBER() OVER (
|
ROW_NUMBER() OVER (
|
||||||
PARTITION BY t1.uuid
|
PARTITION BY t1.uuid
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -294,6 +301,7 @@ class Device:
|
||||||
RankedProperties
|
RankedProperties
|
||||||
WHERE
|
WHERE
|
||||||
row_num = 1
|
row_num = 1
|
||||||
|
ORDER BY created DESC
|
||||||
""".format(
|
""".format(
|
||||||
institution=institution.id,
|
institution=institution.id,
|
||||||
algorithm=institution.algorithm
|
algorithm=institution.algorithm
|
||||||
|
@ -309,6 +317,7 @@ class Device:
|
||||||
SELECT
|
SELECT
|
||||||
t1.value,
|
t1.value,
|
||||||
t1.key,
|
t1.key,
|
||||||
|
t1.created,
|
||||||
ROW_NUMBER() OVER (
|
ROW_NUMBER() OVER (
|
||||||
PARTITION BY t1.uuid
|
PARTITION BY t1.uuid
|
||||||
ORDER BY
|
ORDER BY
|
||||||
|
@ -329,6 +338,7 @@ class Device:
|
||||||
RankedProperties
|
RankedProperties
|
||||||
WHERE
|
WHERE
|
||||||
row_num = 1;
|
row_num = 1;
|
||||||
|
ORDER BY created DESC
|
||||||
""".format(
|
""".format(
|
||||||
uuid=uuid.replace("-", ""),
|
uuid=uuid.replace("-", ""),
|
||||||
institution=institution.id,
|
institution=institution.id,
|
||||||
|
|
Loading…
Reference in a new issue