Ad requirement 4
I have no idea how this requirement shall be implemented at the end, but at first step, the tiss_crawler.rb lib checks if the search_term is an empty string and returns an error msg if found otherwise it returns the result, but appended to 'content' key
This commit is contained in:
parent
72b9f7d7a0
commit
cfcbf5acdb
@ -7,7 +7,14 @@ class Crawlers::CoursesCrawlerController < Crawlers::TissCrawlerController
|
|||||||
@host = TissCrawler.host
|
@host = TissCrawler.host
|
||||||
|
|
||||||
# TissCrawler performs general search over the available courses
|
# TissCrawler performs general search over the available courses
|
||||||
@courses = TissCrawler.search(params)
|
result = TissCrawler.search(params)
|
||||||
|
if result.has_key? :error
|
||||||
|
flash[:alert] = 'Something went wrong! ' + result[:error]
|
||||||
|
redirect_back(fallback_location: crawlers_tiss_crawler_search_path)
|
||||||
|
else
|
||||||
|
# TissCrawler performs general search over the available people
|
||||||
|
@courses = result[:content]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_detail
|
def show_detail
|
||||||
|
|||||||
@ -6,8 +6,16 @@ class Crawlers::PeopleCrawlerController < Crawlers::TissCrawlerController
|
|||||||
puts params[:search_context]
|
puts params[:search_context]
|
||||||
@host = TissCrawler.host
|
@host = TissCrawler.host
|
||||||
|
|
||||||
# TissCrawler performs general search over the available people
|
result = TissCrawler.search(params)
|
||||||
@people = TissCrawler.search(params)
|
|
||||||
|
if result.has_key? :error
|
||||||
|
flash[:alert] = 'Something went wrong! ' + result[:error]
|
||||||
|
redirect_back(fallback_location: crawlers_tiss_crawler_search_path)
|
||||||
|
else
|
||||||
|
# TissCrawler performs general search over the available people
|
||||||
|
@people = result[:content]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_detail
|
def show_detail
|
||||||
@ -39,7 +47,7 @@ class Crawlers::PeopleCrawlerController < Crawlers::TissCrawlerController
|
|||||||
else
|
else
|
||||||
flash[:alert] = 'Person is already favorited!'
|
flash[:alert] = 'Person is already favorited!'
|
||||||
end
|
end
|
||||||
redirect_back(fallback_location: search)
|
redirect_back(fallback_location: crawlers_tiss_crawler_search_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -6,7 +6,14 @@ class Crawlers::ProjectsCrawlerController < Crawlers::TissCrawlerController
|
|||||||
@host = TissCrawler.host
|
@host = TissCrawler.host
|
||||||
|
|
||||||
# TissCrawler performs general search over the available projects
|
# TissCrawler performs general search over the available projects
|
||||||
@projects = TissCrawler.search(params)
|
result = TissCrawler.search(params)
|
||||||
|
if result.has_key? :error
|
||||||
|
flash[:alert] = 'Something went wrong! ' + result[:error]
|
||||||
|
redirect_back(fallback_location: crawlers_tiss_crawler_search_path)
|
||||||
|
else
|
||||||
|
# TissCrawler performs general search over the available people
|
||||||
|
@projects = result[:content]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_detail
|
def show_detail
|
||||||
|
|||||||
@ -6,7 +6,14 @@ class Crawlers::ThesesCrawlerController < Crawlers::TissCrawlerController
|
|||||||
@host = TissCrawler.host
|
@host = TissCrawler.host
|
||||||
|
|
||||||
# TissCrawler performs general search over the available theses
|
# TissCrawler performs general search over the available theses
|
||||||
@theses = TissCrawler.search(params)
|
result = TissCrawler.search(params)
|
||||||
|
if result.has_key? :error
|
||||||
|
flash[:alert] = 'Something went wrong! ' + result[:error]
|
||||||
|
redirect_back(fallback_location: crawlers_tiss_crawler_search_path)
|
||||||
|
else
|
||||||
|
# TissCrawler performs general search over the available people
|
||||||
|
@theses = result[:content]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def show_detail
|
def show_detail
|
||||||
|
|||||||
@ -10,10 +10,15 @@ class TissCrawler
|
|||||||
search_parameter = params[:search_parameter]
|
search_parameter = params[:search_parameter]
|
||||||
search_term = params[:search_term].parameterize(separator: '+')
|
search_term = params[:search_term].parameterize(separator: '+')
|
||||||
url = host + api + '?' + search_parameter + '=' + search_term
|
url = host + api + '?' + search_parameter + '=' + search_term
|
||||||
puts(url)
|
puts('generated url:', url)
|
||||||
|
|
||||||
|
if search_term == ""
|
||||||
|
{'error': 'Dare you try! Empty searches are not allowed!'}
|
||||||
|
else
|
||||||
|
response = HTTParty.get(url)
|
||||||
|
{'content': JSON.parse(response.body)['results']}
|
||||||
|
end
|
||||||
|
|
||||||
response = HTTParty.get(url)
|
|
||||||
JSON.parse(response.body)['results']
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get_details(params)
|
def self.get_details(params)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user