Merge pull request 'ordered from update list of devices' (#55) from timestamp into main
Reviewed-on: #55
This commit is contained in:
commit
29f08a633b
|
@ -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):
|
||||||
|
|
|
@ -143,6 +143,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
|
||||||
|
@ -162,6 +163,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,
|
||||||
|
@ -188,6 +190,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
|
||||||
|
@ -208,6 +211,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
|
||||||
|
@ -225,6 +229,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
|
||||||
|
@ -246,6 +251,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
|
||||||
|
@ -272,6 +278,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
|
||||||
|
@ -293,6 +300,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
|
||||||
|
@ -308,6 +316,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
|
||||||
|
@ -328,6 +337,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