Skip to content

Commit

Permalink
Remove Typeahead Service (#3257)
Browse files Browse the repository at this point in the history
* Remove Typeahead search service to focus on search service to return better results

* Remove unecessary API request params

* remove srchscope now that the queries aren't shared anymore

* update typeahead script to use doc_list instead of tag_list
  • Loading branch information
Stefanni authored and jywarren committed Aug 28, 2018
1 parent 4b0e408 commit 8d51151
Show file tree
Hide file tree
Showing 18 changed files with 74 additions and 809 deletions.
5 changes: 1 addition & 4 deletions app/api/srch/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ class API < Grape::API
format :json

# mount the individual api modules here
mount Srch::Typeahead
mount Srch::Search

# Add the swagger documentation
Expand All @@ -19,9 +18,7 @@ class API < Grape::API
models: [
SearchRequest::Entity,
DocResult::Entity,
TagResult::Entity,
DocList::Entity,
TagList::Entity
DocList::Entity
],
info: {
title: 'RESTful API calls for Public Lab site',
Expand Down
14 changes: 7 additions & 7 deletions app/api/srch/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Search < Grape::API

# Endpoint definitions
resource :srch do
# Request URL should be /api/srch/all?srchString=QRY[&seq=KEYCOUNT&showCount=NUM_ROWS&pageNum=PAGE_NUM]
# Request URL should be /api/srch/all?srchString=QRY
# Basic implementation from classic plots2 SearchController
desc 'Perform a search of all available resources', hidden: false,
is_array: false,
Expand All @@ -21,7 +21,7 @@ class Search < Grape::API
Search.execute(:all, params)
end

# Request URL should be /api/srch/profiles?srchString=QRY[&sort_by=recent&order_direction=desc&field=username&seq=KEYCOUNT&showCount=NUM_ROWS&pageNum=PAGE_NUM]
# Request URL should be /api/srch/profiles?srchString=QRY[&sort_by=recent&order_direction=desc&field=username]
# Basic implementation from classic plots2 SearchController
desc 'Perform a search of profiles', hidden: false,
is_array: false,
Expand All @@ -34,7 +34,7 @@ class Search < Grape::API
Search.execute(:profiles, params)
end

# Request URL should be /api/srch/notes?srchString=QRY[&seq=KEYCOUNT&showCount=NUM_ROWS&pageNum=PAGE_NUM]
# Request URL should be /api/srch/notes?srchString=QRY
# Basic implementation from classic plots2 SearchController
desc 'Perform a search of research notes', hidden: false,
is_array: false,
Expand All @@ -47,7 +47,7 @@ class Search < Grape::API
Search.execute(:notes, params)
end

# Request URL should be /api/srch/questions?srchString=QRY[&seq=KEYCOUNT&showCount=NUM_ROWS&pageNum=PAGE_NUM]
# Request URL should be /api/srch/questions?srchString=QRY
# Basic implementation from classic plots2 SearchController
desc 'Perform a search of questions tables', hidden: false,
is_array: false,
Expand All @@ -60,7 +60,7 @@ class Search < Grape::API
Search.execute(:questions, params)
end

# Request URL should be /api/srch/tags?srchString=QRY[&seq=KEYCOUNT&showCount=NUM_ROWS&pageNum=PAGE_NUM]
# Request URL should be /api/srch/tags?srchString=QRY
# Basic implementation from classic plots2 SearchController
desc 'Perform a search of documents associated with tags within the system', hidden: false,
is_array: false,
Expand All @@ -73,7 +73,7 @@ class Search < Grape::API
Search.execute(:tags, params)
end

# Request URL should be /api/srch/taglocations?srchString=QRY[&tagName=awesome&seq=KEYCOUNT&showCount=NUM_ROWS&pageNum=PAGE_NUM]
# Request URL should be /api/srch/taglocations?srchString=QRY[&tagName=awesome]
# Note: Query(QRY as above) must have latitude and longitude as srchString=lat,lon
desc 'Perform a search of documents having nearby latitude and longitude tag values', hidden: false,
is_array: false,
Expand All @@ -87,7 +87,7 @@ class Search < Grape::API
end

# API TO FETCH QRY RECENT CONTRIBUTORS
# Request URL should be /api/srch/peoplelocations?srchString=QRY[&tagName=group:partsandcrafts&seq=KEYCOUNT&showCount=NUM_ROWS&pageNum=PAGE_NUM]
# Request URL should be /api/srch/peoplelocations?srchString=QRY[&tagName=group:partsandcrafts]
# QRY should be a number
desc 'Perform a search to show x Recent People', hidden: false,
is_array: false,
Expand Down
8 changes: 0 additions & 8 deletions app/api/srch/shared_params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ module SharedParams

params :common do
requires :srchString, type: String, documentation: { example: 'Spec' }
optional :seq, type: Integer, documentation: { example: 995 }
optional :showCount, type: Integer, documentation: { example: 3 }
optional :pageNum, type: Integer, documentation: { example: 0 }
end

params :additional do
Expand All @@ -27,10 +24,5 @@ module SharedParams
optional :field, type: String, documentation: { example: 'username' }
optional :limit, type: Integer, documentation: { example: 0 }
end

params :commontypeahead do
requires :srchString, type: String, documentation: { example: 'Spec' }
optional :seq, type: Integer, documentation: { example: 995 }
end
end
end
103 changes: 0 additions & 103 deletions app/api/srch/typeahead.rb

This file was deleted.

22 changes: 11 additions & 11 deletions app/assets/javascripts/restful_typeahead.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
The restful_typeahead.js script provides generic typeahead functionality for the plots2 Rails app.
The set of functions here are intended to provide a link between the data available through the RESTful
search API and the UI components.
The set of functions here are intended to provide a link between the data available through the RESTful
search API and the UI components.
Documentation here: https://github.com/bassjobsen/Bootstrap-3-Typeahead
**/

Expand All @@ -13,26 +13,26 @@ jQuery(document).ready(function() {
minLength: 3,
autoSelect: false,
source: function (query, process) {
return $.getJSON('/api/typeahead/all?srchString=' + query, function (data) {
return $.getJSON('/api/search/all?srchString=' + query, function (data) {
return process(data.items);
},'json');
},
highlighter: function (text, item) {
return '<i class="fa fa-' + item.tagType + '"></i> ' + item.tagVal;
return '<i class="fa fa-' + item.docType + '"></i> ' + item.docTitle;
},
matcher: function() {
return true;
},
displayText: function(item) {
return item.tagVal;
return item.docTitle;
},
updater: function(item) {
if (item.hasOwnProperty('tagSource') && item.tagSource) {
window.location = window.location.origin + item.tagSource;
updater: function(item) {
if (item.hasOwnProperty('docUrl') && item.docUrl) {
window.location = window.location.origin + item.docUrl;
} else {
window.location = window.location.origin + '/tag/' + item.tagVal;
window.location = window.location.origin + '/tag/' + item.docTitle;
}
item = item.tagVal;
item = item.docTitle;
return item;
}
});
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/searches_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def new; end
def results
@title = 'Search'
@tagnames = params[:id].split(',')
@users = SrchScope.find_users(params[:id], limit = nil)
@nodes = TypeaheadService.new.nodes(params[:id], 100, params[:order].to_s.to_sym)
@users = SearchService.new.find_users(params[:id], limit = 10)
@nodes = SearchService.new.find_nodes(params[:id], 100, params[:order].to_s.to_sym)
.paginate(page: params[:page], per_page: 24)
end
end
32 changes: 0 additions & 32 deletions app/models/tag_list.rb

This file was deleted.

24 changes: 0 additions & 24 deletions app/models/tag_result.rb

This file was deleted.

28 changes: 0 additions & 28 deletions app/services/execute_typeahead.rb

This file was deleted.

Loading

0 comments on commit 8d51151

Please sign in to comment.