diff --git a/controllers/recommender_v1_controller.rb b/controllers/recommender_v1_controller.rb index 5b0123a9..29991299 100644 --- a/controllers/recommender_v1_controller.rb +++ b/controllers/recommender_v1_controller.rb @@ -1,17 +1,10 @@ class RecommenderController < ApplicationController namespace "/recommender_v1" do - # execute an annotator query + # Mark this route as deprecated get do - text = params["text"] - raise error 400, "A text to be analyzed by the recommender must be supplied using the argument text=" if text.nil? || text.strip.empty? - acronyms = restricted_ontologies_to_acronyms(params) - display_classes = params['display_classes'].eql?('true') # default will be false - recommender = Recommender::Models::NcboRecommender.new - recommendations = recommender.recommend(text, acronyms, display_classes) - reply 200, recommendations + reply 410, { message: "This API endpoint has been deprecated and is no longer available. Please use /recommender or refer to the API documentation for updated routes." } end end end - diff --git a/test/controllers/test_recommender_v1_controller.rb b/test/controllers/test_recommender_v1_controller.rb index 01bde871..7ef09cee 100644 --- a/test/controllers/test_recommender_v1_controller.rb +++ b/test/controllers/test_recommender_v1_controller.rb @@ -1,40 +1,10 @@ require_relative '../test_case' - +# recommender_v1 is deprecated as of 2024-10-27 +# TODO: remove completely after 2025-10-27 class TestRecommenderV1Controller < TestCase - - def before_suite - LinkedData::SampleData::Ontology.delete_ontologies_and_submissions - @@ontologies = LinkedData::SampleData::Ontology.sample_owl_ontologies(process_submission: true) - @@text = < @@text - } + def test_recommender_v1_deprecation + params = { text: 'recommender v1 is deprecated' } get "/recommender_v1", params - assert last_response.ok? - recommendations = MultiJson.load(last_response.body) - assert_instance_of(Array, recommendations) - assert_equal(3, recommendations.length, msg='Failed to return 3 recommendations') - rec = recommendations.first - assert_instance_of(Hash, rec) - ont_acronyms = @@ontologies.map {|o| o.bring(:acronym); o.acronym } - assert ont_acronyms.include? rec['ontology']['acronym'] - assert rec['annotatedClasses'].length == 0 # no classes requested - assert rec['numTermsMatched'] > 0 - assert rec['numTermsTotal'] > 0 - assert rec['numTermsTotal'] >= rec['numTermsMatched'] - assert recommendations[0]['score'].to_i >= recommendations[1]['score'].to_i - assert recommendations[1]['score'].to_i >= recommendations[2]['score'].to_i + assert_equal 410, last_response.status end - end