diff --git a/app/controllers/saved_searches_controller.rb b/app/controllers/saved_searches_controller.rb
index b13a94713d1..ca3cb4f2cb7 100644
--- a/app/controllers/saved_searches_controller.rb
+++ b/app/controllers/saved_searches_controller.rb
@@ -10,11 +10,11 @@ class SavedSearchesController < ApplicationController
].freeze
def index
- searches = organization.users.map(&:saved_searches).flatten
- my_search = SavedSearch.for_user(current_user)
respond_to do |format|
format.html { render "index" }
format.json do
+ searches = organization.users.includes(:saved_searches).map(&:saved_searches).flatten
+ my_search = SavedSearch.for_user(current_user)
render json:
{ all_searches: SavedSearchSerializer.new(searches).serializable_hash[:data],
user_searches: SavedSearchSerializer.new(my_search).serializable_hash[:data] }
@@ -24,9 +24,10 @@ def index
def show
@search = SavedSearch.find_by_id(params[:id])
+ @search_json = SavedSearchSerializer.new(@search).serializable_hash[:data]
respond_to do |format|
format.html { render "show" }
- format.json { render json: SavedSearchSerializer.new(@search).serializable_hash[:data] }
+ format.json { render json: @search_json }
end
end
@@ -48,10 +49,12 @@ def destroy
end
end
+ helper_method :organization
+
private
def organization
- @organization ||= BusinessLine.find_by(url: params[:decision_review_business_line_slug])
+ @organization ||= Organization.find_by(url: params[:decision_review_business_line_slug])
end
def save_search_create_params
diff --git a/app/models/saved_search.rb b/app/models/saved_search.rb
index 76d8844d8c2..98353ca9110 100644
--- a/app/models/saved_search.rb
+++ b/app/models/saved_search.rb
@@ -7,7 +7,6 @@ class SavedSearch < CaseflowRecord
validates :description, presence: true, length: { maximum: 1000 }
validate :saved_search_limit
- # Ex:- scope :active, -> {where(:active => true)}
scope :for_user, ->(user) { where(user: user).order(created_at: :desc) }
private
diff --git a/app/serializers/saved_search_serializer.rb b/app/serializers/saved_search_serializer.rb
index d69943c4eb6..1d13ef81275 100644
--- a/app/serializers/saved_search_serializer.rb
+++ b/app/serializers/saved_search_serializer.rb
@@ -7,13 +7,13 @@ class SavedSearchSerializer
attribute :description
attribute :savedSearch, &:saved_search
attribute :createdAt, &:created_at
- attribute :userCssId do |object|
- object.user.css_id
- end
- attribute :userFullName do |object|
- object.user.full_name
- end
- attribute :userId do |object|
- object.user.id
+
+ attribute :user do |object|
+ user = object.try(:user)
+ {
+ css_id: user.try(:css_id),
+ full_name: user.try(:full_name),
+ id: user.id
+ }
end
end
diff --git a/app/views/saved_searches/index.html.erb b/app/views/saved_searches/index.html.erb
index af39cb940ef..97e9b9b133b 100644
--- a/app/views/saved_searches/index.html.erb
+++ b/app/views/saved_searches/index.html.erb
@@ -7,9 +7,12 @@
buildDate: build_date,
flash: flash,
serverNonComp: {
+ businessLine: organization.name,
+ businessLineUrl: organization.url,
currentUserCssId: current_user.css_id,
},
savedSearches: {
+
}
}) %>
<% end %>
diff --git a/app/views/saved_searches/show.html.erb b/app/views/saved_searches/show.html.erb
index af39cb940ef..5139095c181 100644
--- a/app/views/saved_searches/show.html.erb
+++ b/app/views/saved_searches/show.html.erb
@@ -10,6 +10,7 @@
currentUserCssId: current_user.css_id,
},
savedSearches: {
+ @search_json
}
}) %>
<% end %>
diff --git a/client/app/nonComp/index.jsx b/client/app/nonComp/index.jsx
index c4d5ce981b3..fb61c716cd2 100644
--- a/client/app/nonComp/index.jsx
+++ b/client/app/nonComp/index.jsx
@@ -59,7 +59,7 @@ class NonComp extends React.PureComponent {
/>