internal/host: sort public_id descending

The previous sort would run the risk of missing items which
collide on update or create times because of the compound
comparison using strictly less than for both the timestamp
and the public_id. Sorting both descending avoids thi issue.
This commit is contained in:
Johan Brandhorst-Satzkorn committed 2024-01-05 07:43:21 -08:00
1 parent d4f5677858
commit d94a25bbd2
3 files changed
+20 -20

No files matched your search

+8 -8
View File
@@ -72,7 +72,7 @@ with hosts as (
version
from host_plugin_host
where catalog_id = @catalog_id
order by create_time desc, public_id asc
order by create_time desc, public_id desc
limit %d
),
host_catalog as (
@@ -126,7 +126,7 @@ final as (
)
select *
from final
order by create_time desc, public_id asc;
order by create_time desc, public_id desc;
`
listHostsPageTemplate = `
@@ -143,7 +143,7 @@ with hosts as (
from host_plugin_host
where catalog_id = @catalog_id
and (create_time, public_id) < (@last_item_create_time, @last_item_id)
order by create_time desc, public_id asc
order by create_time desc, public_id desc
limit %d
),
host_catalog as (
@@ -197,7 +197,7 @@ final as (
)
select *
from final
order by create_time desc, public_id asc;
order by create_time desc, public_id desc;
`
listHostsRefreshTemplate = `
@@ -214,7 +214,7 @@ with hosts as (
from host_plugin_host
where catalog_id = @catalog_id
and update_time > @updated_after_time
order by update_time desc, public_id asc
order by update_time desc, public_id desc
limit %d
),
host_catalog as (
@@ -268,7 +268,7 @@ final as (
)
select *
from final
order by update_time desc, public_id asc;
order by update_time desc, public_id desc;
`
listHostsRefreshPageTemplate = `
@@ -286,7 +286,7 @@ with hosts as (
where catalog_id = @catalog_id
and update_time > @updated_after_time
and (update_time, public_id) < (@last_item_update_time, @last_item_id)
order by update_time desc, public_id asc
order by update_time desc, public_id desc
limit %d
),
host_catalog as (
@@ -340,7 +340,7 @@ final as (
)
select *
from final
order by update_time desc, public_id asc;
order by update_time desc, public_id desc;
`
estimateCountHostSets = `