Skip to content

Commit

Permalink
fix(posts): Pull results out of the cache in descending order.
Browse files Browse the repository at this point in the history
  • Loading branch information
randytarampi committed Aug 19, 2018
1 parent 8cd22de commit 48ab8e2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 3 additions & 1 deletion packages/posts/lib/searchParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ class SearchParams extends Record({
}

get Dynamoose() {
const options = {};
const options = {
descending: true
};

if (this.perPage) {
options.limit = this.perPage;
Expand Down
7 changes: 4 additions & 3 deletions packages/posts/test/unit/lib/cachedDataSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ describe("CachedDataSource", function () {
hash: {type: {eq: "Photo"}},
options: {
indexName: "type-source-index",
limit: 100
limit: 100,
descending: true
},
range: {source: {eq: stubType}}
});
Expand Down Expand Up @@ -291,7 +292,7 @@ describe("CachedDataSource", function () {
expect(stubGetPost.calledOnce).to.eql(true);
sinon.assert.calledWith(stubGetPost, {
uid: {eq: stubPost.uid},
options: {limit: 100}
options: {limit: 100, descending: true}
});
});
});
Expand All @@ -307,7 +308,7 @@ describe("CachedDataSource", function () {
expect(stubGetPost.calledOnce).to.eql(true);
sinon.assert.calledWith(stubGetPost, {
uid: {eq: stubPost.uid},
options: {limit: 100}
options: {limit: 100, descending: true}
});
});
});
Expand Down
17 changes: 9 additions & 8 deletions packages/posts/test/unit/lib/searchParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe("SearchParams", function () {

expect(searchParams.Dynamoose).to.eql({
uid: {eq: "woof"},
options: {limit: 100}
options: {limit: 100, descending: true}
});
});

Expand All @@ -108,7 +108,7 @@ describe("SearchParams", function () {

expect(searchParams.Dynamoose).to.eql({
type: {eq: "woof"},
options: {limit: 100}
options: {limit: 100, descending: true}
});
});

Expand All @@ -117,7 +117,7 @@ describe("SearchParams", function () {

expect(searchParams.Dynamoose).to.eql({
source: {eq: "meow"},
options: {limit: 100}
options: {limit: 100, descending: true}
});
});

Expand All @@ -127,7 +127,7 @@ describe("SearchParams", function () {
expect(searchParams.Dynamoose).to.eql({
hash: {type: {eq: "woof"}},
range: {source: {eq: "meow"}},
options: {indexName: "type-source-index", limit: 100}
options: {indexName: "type-source-index", limit: 100, descending: true}
});
});

Expand All @@ -142,7 +142,7 @@ describe("SearchParams", function () {
expect(searchParams.Dynamoose).to.eql({
hash: {type: {eq: "woof"}},
range: {meow: {lt: "grr"}},
options: {indexName: "type-meow-index", limit: 100}
options: {indexName: "type-meow-index", limit: 100, descending: true}
});
});

Expand All @@ -151,7 +151,7 @@ describe("SearchParams", function () {

expect(searchParams.Dynamoose).to.eql({
uid: {eq: `meow${util.compositeKeySeparator}woof`},
options: {limit: 100}
options: {limit: 100, descending: true}
});
});

Expand All @@ -166,7 +166,7 @@ describe("SearchParams", function () {
expect(searchParams.Dynamoose).to.eql({
hash: {source: {eq: "woof"}},
range: {meow: {gt: "grr"}},
options: {indexName: "source-meow-index", limit: 100}
options: {indexName: "source-meow-index", limit: 100, descending: true}
});
});

Expand All @@ -184,7 +184,8 @@ describe("SearchParams", function () {
range: {meow: {gt: "grr"}},
options: {
indexName: "source-meow-index",
limit: 20
limit: 20,
descending: true
}
});
});
Expand Down

0 comments on commit 48ab8e2

Please sign in to comment.