-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#919710] Ensure only published makes are returned from general search, ... #151
base: master
Are you sure you want to change the base?
Changes from 2 commits
e7bd0e2
ed2adec
df118fc
fe94780
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,25 @@ module.exports = function( makeModel, env ) { | |
doSearch( req, res, dsl ); | ||
}); | ||
}, | ||
authenticatedSearch: function( req, res ) { | ||
|
||
if ( !req.query ) { | ||
return searchError( res, "Malformed Request", 400 ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to use the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the one below it, line 173 is fine? nvm, looks like you saw that a bit later. |
||
} | ||
|
||
queryBuilder.authenticatedSearch( req.query, function( err, dsl ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this applies to lines 171. Line 173 should use hawkError |
||
if ( err ) { | ||
if ( err.code === 404 ) { | ||
// No user was found, no makes to search. | ||
metrics.increment( "make.search.success" ); | ||
return res.json( { makes: [], total: 0 } ); | ||
} else { | ||
return searchError( res, err, err.code ); | ||
} | ||
} | ||
doSearch( req, res, dsl ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to figure out how to get doSearch to sign the response with hawk, without breaking regular search. |
||
}); | ||
}, | ||
searchTest: function( req, res ) { | ||
res.render( "search.html" ); | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,10 +7,19 @@ module.exports = function( qb ){ | |
match_all: {} | ||
}, | ||
filter: { | ||
missing: { | ||
field: "deletedAt", | ||
null_value: true | ||
} | ||
and: [ | ||
{ | ||
missing: { | ||
field: "deletedAt", | ||
null_value: true | ||
} | ||
}, | ||
{ | ||
term: { | ||
published: true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
|
@@ -62,6 +71,8 @@ module.exports = function( qb ){ | |
assert.strictEqual( err, null ); | ||
}); | ||
it( "built query should match the defined base query", function() { | ||
console.log("query", query); | ||
console.log("baseQuery", baseQuery); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove these. |
||
assert.deepEqual( query, baseQuery ); | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check that customFilter exists, or default it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you're defaulting it below when it's referenced for baseQuery - that should be fine, but perhaps you could shorthand it so that
buildQuery( query, callback )
works alongside the three argument version. Worth it?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I agree with this.
Why burden the calls that don't care about filters to have to worry about filters.