From b9a7d03a4cea13f7e029bef00e85d16d2f7b80fd Mon Sep 17 00:00:00 2001 From: Loren Johnson Date: Fri, 6 Mar 2020 13:01:45 -0800 Subject: [PATCH 1/2] Fix pagination by time to filter entries from_time into the past (desc) --- app_spec/test/files/links.js | 8 ++++---- crates/core/src/dht/dht_store.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app_spec/test/files/links.js b/app_spec/test/files/links.js index 494b6ad513..c984d60607 100644 --- a/app_spec/test/files/links.js +++ b/app_spec/test/files/links.js @@ -148,8 +148,8 @@ module.exports = scenario => { limit:3 }) - t.equal(0, bob_posts_live_time.Ok.links.length) - t.equal(0, alice_posts_live_time.Ok.links.length) + t.equal(3, bob_posts_live_time.Ok.links.length) + t.equal(3, alice_posts_live_time.Ok.links.length) const bob_posts_time_2 = await bob.call('app', 'simple', 'get_my_links_with_time_pagination', { @@ -165,8 +165,8 @@ module.exports = scenario => { limit:3 }) - t.equal(3, bob_posts_time_2.Ok.links.length) - t.equal(3, alice_posts_time_2.Ok.links.length) + t.equal(0, bob_posts_time_2.Ok.links.length) + t.equal(0, alice_posts_time_2.Ok.links.length) }) scenario('get_links_crud', async (s, t) => { diff --git a/crates/core/src/dht/dht_store.rs b/crates/core/src/dht/dht_store.rs index e718a4ed98..23147a4271 100644 --- a/crates/core/src/dht/dht_store.rs +++ b/crates/core/src/dht/dht_store.rs @@ -188,7 +188,7 @@ impl DhtStore { .skip_while(move |eavi| { let from_time: DateTime = paginated_time.from_time.into(); - from_time.timestamp_nanos() >= eavi.index() + from_time.timestamp_nanos() <= eavi.index() }) .take(time_pagination.limit), ) From b5abaa4f660696a4007c9064c03b35aa55ce6354 Mon Sep 17 00:00:00 2001 From: Loren Johnson Date: Fri, 6 Mar 2020 13:10:43 -0800 Subject: [PATCH 2/2] Updated changelog and docs for get_links time pagination fix --- CHANGELOG-UNRELEASED.md | 1 + doc/holochain_101/src/links/get_links.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG-UNRELEASED.md b/CHANGELOG-UNRELEASED.md index 698710a742..a44cacdcef 100644 --- a/CHANGELOG-UNRELEASED.md +++ b/CHANGELOG-UNRELEASED.md @@ -16,5 +16,6 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Older rust-tracing traces. ### Fixed +- Pagination option for get_links now retrieves entries before `from_time`, not after [PR#2144](https://github.com/holochain/holochain-rust/pull/2144) ### Security diff --git a/doc/holochain_101/src/links/get_links.md b/doc/holochain_101/src/links/get_links.md index 513e402ee2..0879394d0b 100644 --- a/doc/holochain_101/src/links/get_links.md +++ b/doc/holochain_101/src/links/get_links.md @@ -10,7 +10,7 @@ Get Links allows the zome developer to query links from the DHT. The call accept `Timeout` : The timeout variable on the options specifies how long the query process should wait befor a response before it timesout `LinksStatusRequest` : This is a variable in which you can specify 3 modes, `All`,`Live`,`Delete`. This allows you to query the links based on crud_status in which `All` will return everything will `Live` will only return live links and `Delete` as such. `Headers`: boolean value which if set to true indicates that the link headers should also be returned.``` -`Pagination`: The pagination type has two variants which are `Size` and `Time` These variants allow the user to paginate based on choosing pages and specifying page size, or by specifying a point time and specifying a limit of the number of entries (based on the timestamp in the entry header) to return from that point. +`Pagination`: The pagination type has two variants which are `Size` and `Time` These variants allow the user to paginate based on choosing pages and specifying page size, or by specifying a point in time and specifying a limit of the number of entries (based on the timestamp in the entry header) to return before that point. `Sort Order` : Allows get_links to define which order `Ascending` or `Descending` the links should be returned in # Link Results