Skip to content

Commit

Permalink
HOTFIX: querying by capture_time + source_type
Browse files Browse the repository at this point in the history
Querying by capture_time in combination with other version parameters (`hash`, `source_type`) was broken in the maintainers update. In addition, I'm not sure why I flipped it to a left_outer_joins in the first place, which is clearly the wrong join for this particular query. I think this must have been a mistaken thing that got committed when I was trying to get all the various query params to work happily together.
  • Loading branch information
Mr0grog committed Feb 20, 2018
1 parent f5db2f7 commit a86b9d1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/api/v0/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def page_collection

version_params = params.permit(:hash, :source_type)
if version_params.present?
collection = collection.left_outer_joins(:versions).where(versions: {
collection = collection.joins(:versions).where(versions: {
version_hash: params[:hash],
source_type: params[:source_type]
}.compact)
Expand Down
9 changes: 9 additions & 0 deletions test/controllers/api/v0/pages_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -532,4 +532,13 @@ def get_all_pages(url)
assert_equal(3, body['meta']['total_results'])
assert_equal(3, body['data'].length)
end

test 'can query pages by capture time and source type together' do
sign_in users(:alice)
get api_v0_pages_path(params: {
capture_time: '2017-03-01T00:00:00Z..2017-03-01T12:00:00Z',
source_type: 'versionista'
})
assert_response :success
end
end

0 comments on commit a86b9d1

Please sign in to comment.