Skip to content
This repository was archived by the owner on Apr 22, 2024. It is now read-only.

Commit 2c50555

Browse files
committed
Fix wrong type comparison for facet search
1 parent 2379e83 commit 2c50555

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

common/models/utils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ exports.createNewFacetPipeline = function (name, type, query) {
128128
}
129129
}
130130
};
131-
if (type === "date") {
131+
if (type === "Date") {
132132
grp.$group._id = {
133133
year: {
134134
$year: "$" + name

test/Dataset.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,21 @@ describe("Simple Dataset tests", () => {
202202
done();
203203
});
204204
});
205+
206+
it("should contain an array of facets aggregated by creationTime %Y-%m-%d", function(done) {
207+
const facets = ["type","creationTime"];
208+
request(app)
209+
.get(`/api/v3/Datasets/fullfacet?access_token=${accessToken}&facets=${JSON.stringify(facets)}`)
210+
.set("Accept", "application/json")
211+
.expect(200)
212+
.expect("Content-Type", /json/)
213+
.end((err, res) => {
214+
if (err) return done(err);
215+
res.body.should.be.an("array");
216+
res.body[0].creationTime[0]._id.should.be.eql({ year:2011,month:9,day:14 });
217+
done();
218+
});
219+
});
205220

206221
it("should delete this dataset", function(done) {
207222
request(app)

0 commit comments

Comments
 (0)