Skip to content

Commit

Permalink
Merge pull request #231 from edgi-govdata-archiving/hotfix-capture-ti…
Browse files Browse the repository at this point in the history
…me-and-other-version-data-on-page-queries

HOTFIX: querying by capture_time + source_type/hash
  • Loading branch information
Mr0grog committed Feb 20, 2018
2 parents f5db2f7 + a86b9d1 commit b4946b0
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 b4946b0

Please sign in to comment.