diff --git a/app/controllers/saved_searches_controller.rb b/app/controllers/saved_searches_controller.rb deleted file mode 100644 index 5dcce1d6e..000000000 --- a/app/controllers/saved_searches_controller.rb +++ /dev/null @@ -1,60 +0,0 @@ -class SavedSearchesController < ApplicationController - before_action :check_availability - respond_to :html, :xml, :json, :js - - def index - @saved_searches = saved_searches.order("id") - - if params[:label] - @saved_searches = saved_searches.labeled(params[:label]) - end - - respond_with(@saved_searches) do |format| - format.xml do - render :xml => @saved_searches.to_xml(:root => "saved-searches") - end - end - end - - def labels - @labels = SavedSearch.search_labels(CurrentUser.id, params[:search]) - respond_with(@labels) - end - - def create - @saved_search = saved_searches.create(saved_search_params) - respond_with(@saved_search) - end - - def destroy - @saved_search = saved_searches.find(params[:id]) - @saved_search.destroy - respond_with(@saved_search) - end - - def edit - @saved_search = saved_searches.find(params[:id]) - end - - def update - @saved_search = saved_searches.find(params[:id]) - @saved_search.update(saved_search_params) - respond_with(@saved_search, :location => saved_searches_path) - end - - private - - def saved_searches - CurrentUser.user.saved_searches - end - - def check_availability - if !SavedSearch.enabled? - raise NotImplementedError.new("Saved searches are not available.") - end - end - - def saved_search_params - params.fetch(:saved_search, {}).permit(%i[query label_string]) - end -end diff --git a/app/javascript/src/javascripts/autocomplete.js.erb b/app/javascript/src/javascripts/autocomplete.js.erb index 7f094cf52..a60b91e9b 100644 --- a/app/javascript/src/javascripts/autocomplete.js.erb +++ b/app/javascript/src/javascripts/autocomplete.js.erb @@ -1,5 +1,4 @@ import Utility from './utility' -import SavedSearch from './saved_searches' let Autocomplete = {}; @@ -152,9 +151,6 @@ Autocomplete.initialize_tag_autocomplete = function() { case "ordpool": Autocomplete.pool_source(term, resp, metatag); break; - case "search": - Autocomplete.saved_search_source(term, resp); - break; default: Autocomplete.normal_source(term, resp); break; @@ -482,17 +478,6 @@ Autocomplete.pool_source = function(term, resp, metatag) { }); } -Autocomplete.saved_search_source = function(term, resp) { - return SavedSearch.labels(term).then(function(labels) { - resp(labels.map(function(label) { - return { - label: label.replace(/_/g, " "), - value: "search:" + label, - }; - })); - }); -} - $(document).ready(function() { Autocomplete.initialize_all(); }); diff --git a/app/javascript/src/javascripts/posts.js.erb b/app/javascript/src/javascripts/posts.js.erb index cefd27af6..81e73810b 100644 --- a/app/javascript/src/javascripts/posts.js.erb +++ b/app/javascript/src/javascripts/posts.js.erb @@ -2,7 +2,6 @@ import Utility from './utility' import Hammer from 'hammerjs' import LS from './local_storage' import Note from './notes' -import SavedSearch from './saved_searches' import { SendQueue } from './send_queue' let Post = {}; @@ -14,7 +13,6 @@ Post.initialize_all = function() { if ($("#c-posts").length) { this.initialize_shortcuts(); - this.initialize_saved_searches(); } if ($("#c-posts").length && $("#a-index").length) { @@ -43,10 +41,6 @@ Post.initialize_all = function() { var $fields_multiple = $('[data-autocomplete="tag-edit"]'); $fields_multiple.on("keypress.danbooru", Post.update_tag_count); $fields_multiple.on("click", Post.update_tag_count); - - $(window).on('danbooru:initialize_saved_seraches', () => { - Post.initialize_saved_searches(); - }); } Post.initialize_voting = function() { @@ -675,53 +669,6 @@ Post.approve = function(post_id) { }); } -Post.initialize_saved_searches = function() { - $("#new_saved_search #saved_search_label_string").autocomplete({ - search: function() { - $(this).data("ui-autocomplete").menu.bindings = $(); - }, - source: function(req, resp) { - SavedSearch.labels(req.term).then(function(labels) { - resp(labels.map(function(label) { - return { - label: label.replace(/_/g, " "), - value: label - }; - })); - }); - } - }); - - $("#save-search-dialog").dialog({ - width: 500, - modal: true, - autoOpen: false, - buttons: { - "Submit": function() { - $("#save-search-dialog form").submit(); - $(this).dialog("close"); - }, - "Cancel": function() { - $(this).dialog("close"); - } - } - }); - - $("#save-search").on("click.danbooru", function(e) { - $("#save-search-dialog #saved_search_query").val($("#tags").val()); - $.post( - "/saved_searches.js", - { - "saved_search": { - "query": $("#tags").val() - } - } - ); - - e.preventDefault(); - }); -} - Post.update_tag_count = function(event) { let string = "0 tags"; let count = 0; diff --git a/app/javascript/src/javascripts/saved_searches.js b/app/javascript/src/javascripts/saved_searches.js deleted file mode 100644 index af0069c45..000000000 --- a/app/javascript/src/javascripts/saved_searches.js +++ /dev/null @@ -1,18 +0,0 @@ -let SavedSearch = {}; - -SavedSearch.initialize_all = function() { - if ($("#c-saved-searches").length) { - $("#c-saved-searches table").stupidtable(); - } -} - -SavedSearch.labels = function(term) { - return $.getJSON("/saved_searches/labels", { - "search[label]": term + "*", - "limit": 10 - }); -} - -$(SavedSearch.initialize_all); - -export default SavedSearch diff --git a/app/jobs/saved_search_job.rb b/app/jobs/saved_search_job.rb deleted file mode 100644 index 4ef4c2bd4..000000000 --- a/app/jobs/saved_search_job.rb +++ /dev/null @@ -1,7 +0,0 @@ -class SavedSearchJob < ApplicationJob - queue_as :default - - def perform(*args) - SavedSearch.populate(args[0]) - end -end diff --git a/app/jobs/tag_batch_job.rb b/app/jobs/tag_batch_job.rb index cc1d53fab..f110e9747 100644 --- a/app/jobs/tag_batch_job.rb +++ b/app/jobs/tag_batch_job.rb @@ -15,7 +15,6 @@ class TagBatchJob < ApplicationJob CurrentUser.without_safe_mode do CurrentUser.scoped(updater, @updater_ip_addr) do migrate_posts(normalized_antecedent, normalized_consequent) - migrate_saved_searches(normalized_antecedent, normalized_consequent) migrate_blacklists(normalized_antecedent, normalized_consequent) end end @@ -35,19 +34,6 @@ class TagBatchJob < ApplicationJob end end - def migrate_saved_searches(normalized_antecedent, normalized_consequent) - if SavedSearch.enabled? - tags = Tag.scan_tags(normalized_antecedent.join(" "), strip_metatags: true) - - # https://www.postgresql.org/docs/current/static/functions-array.html - saved_searches = SavedSearch.where("string_to_array(query, ' ') @> ARRAY[?]", tags) - saved_searches.find_each do |ss| - ss.query = (ss.query.split - tags + normalized_consequent).uniq.join(" ") - ss.save - end - end - end - # this can't handle negated tags or other special cases def migrate_blacklists(normalized_antecedent, normalized_consequent) query = normalized_antecedent diff --git a/app/jobs/user_deletion_job.rb b/app/jobs/user_deletion_job.rb index 540e20503..60cf9ee16 100644 --- a/app/jobs/user_deletion_job.rb +++ b/app/jobs/user_deletion_job.rb @@ -6,7 +6,6 @@ class UserDeletionJob < ApplicationJob remove_favorites(user) - remove_saved_searches(user) rename(user) end @@ -18,10 +17,6 @@ class UserDeletionJob < ApplicationJob end end - def remove_saved_searches(user) - SavedSearch.where(user_id: user.id).destroy_all - end - def rename(user) name = "user_#{user.id}" n = 0 diff --git a/app/logical/elastic_post_query_builder.rb b/app/logical/elastic_post_query_builder.rb index b8461d42a..9fc3c63c2 100644 --- a/app/logical/elastic_post_query_builder.rb +++ b/app/logical/elastic_post_query_builder.rb @@ -61,21 +61,6 @@ class ElasticPostQueryBuilder }}) end - def saved_search_relation(saved_searches, should) - if SavedSearch.enabled? - saved_searches.map do |saved_search| - if saved_search == "all" - post_ids = SavedSearch.post_ids_for(CurrentUser.id) - else - post_ids = SavedSearch.post_ids_for(CurrentUser.id, label: saved_search) - end - - post_ids = [] if post_ids.empty? - should.push({terms: {id: post_ids}}) - end - end - end - def table_for_metatag(metatag) if metatag.in?(Tag::COUNT_METATAGS) metatag[/(?
Query | -Labels | -- |
---|---|---|
<%= link_to ss.query, posts_path(:tags => ss.query) %> | -- <% ss.labels.each do |label| %> - <%= link_to label, posts_path(:tags => "search:#{label}") %> - <% end %> - | -- <%= link_to "edit", edit_saved_search_path(ss) %> - | <%= link_to "delete", saved_search_path(ss), :method => :delete, :remote => true %> - | -