-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Address expiry of studies from clinicaltrials.gov
Added a task to un-publish trials that are no longer in the list of recruiting trials for the location that is being used to pull from clinicaltrials.gov. - Refactored ctgov connector nct_ids_for_location method to use current ct.gov API. Also uses recursion without passing arrays of IDs into a new method invocation for memory benefits. - In same method, include filter for only recruiting studies at location. - Allow cleanup_stray_trials and stray_trials to accept an argument of an array of IDs that should be considered "still recruiting"; this can be leveraged for testing bc there isn't a great way to mock ct.gov API responses given the current state of coupling in the connector. - Tests for these updates.
- Loading branch information
1 parent
89aeea5
commit 6e9a639
Showing
5 changed files
with
119 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'rails_helper' | ||
require 'connectors/ctgov' | ||
|
||
describe Connectors::Ctgov do | ||
context "cleanup_stray_trials" do | ||
it "hides trials that are no longer actively recruiting at the given location(s)" do | ||
parser = create(:parser) | ||
system_info = create(:system_info, initials: 'TSTU') | ||
ctgov = Connectors::Ctgov.new | ||
will_hide = create(:trial, parser: parser) | ||
wont_hide = create_list(:trial, 5, parser: parser) | ||
remaining_ids = wont_hide.map { |e| e.nct_id } | ||
|
||
expect(will_hide.visible).to be_truthy | ||
expect(wont_hide.first.visible).to be_truthy | ||
|
||
strays = ctgov.stray_trials(remaining_ids) | ||
expect(strays.map { |e| e.nct_id }).to include(will_hide.nct_id) | ||
|
||
ctgov.cleanup_stray_trials(remaining_ids) | ||
will_hide.reload | ||
expect(will_hide.visible).to be_falsey | ||
expect(wont_hide.first.visible).to be_truthy | ||
end | ||
|
||
it "does not hide trials from a different parser" do | ||
parser = create(:parser) | ||
parser2 = create(:parser, name: 'foobar', klass: 'Parsers::Foobar') | ||
system_info = create(:system_info, initials: 'TSTU') | ||
ctgov = Connectors::Ctgov.new | ||
will_hide = create(:trial, parser: parser) | ||
wont_hide = create_list(:trial, 5, parser: parser) | ||
wont_hide_2 = create(:trial, parser: parser2) | ||
remaining_ids = wont_hide.map { |e| e.nct_id } | ||
|
||
expect(will_hide.visible).to be_truthy | ||
expect(wont_hide_2.visible).to be_truthy | ||
|
||
ctgov.cleanup_stray_trials(remaining_ids) | ||
will_hide.reload | ||
|
||
expect(will_hide.visible).to be_falsey | ||
expect(wont_hide_2.visible).to be_truthy | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :parser do | ||
name { 'clinicaltrials.gov' } | ||
klass { 'Parsers::Ctgov' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters