From 97da8f86472bbc1878d2fe999cf17b95f34e0d60 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Fri, 14 Apr 2017 16:00:20 -0700 Subject: [PATCH] deprecate tag subscriptions with warnings --- app/assets/javascripts/autocomplete.js | 33 +------------------ .../tag_subscriptions_controller.rb | 7 ++++ app/logical/daily_maintenance.rb | 1 - app/logical/post_query_builder.rb | 26 --------------- app/logical/post_sets/post.rb | 12 ------- app/logical/user_deletion.rb | 5 +++ app/models/tag.rb | 4 --- app/presenters/post_set_presenters/post.rb | 2 -- app/presenters/user_presenter.rb | 22 ------------- .../posts/partials/index/_related.html.erb | 4 --- .../_secondary_links.html.erb | 3 -- app/views/tag_subscriptions/index.html.erb | 9 +++-- app/views/tag_subscriptions/new.html.erb | 6 ++-- app/views/tag_subscriptions/posts.html.erb | 24 -------------- app/views/users/_secondary_links.html.erb | 3 -- app/views/users/_statistics.html.erb | 8 +---- 16 files changed, 22 insertions(+), 147 deletions(-) delete mode 100644 app/views/tag_subscriptions/posts.html.erb diff --git a/app/assets/javascripts/autocomplete.js b/app/assets/javascripts/autocomplete.js index cff9197ab..ee20bd969 100644 --- a/app/assets/javascripts/autocomplete.js +++ b/app/assets/javascripts/autocomplete.js @@ -89,7 +89,7 @@ Danbooru.Autocomplete.initialize_tag_autocomplete = function() { var $fields_multiple = $( "#tags,#post_tag_string,#upload_tag_string,#tag-script-field,#c-moderator-post-queues #query," + - "#user_blacklisted_tags,#user_favorite_tags,#tag_subscription_tag_query,#search_post_tags_match" + "#user_blacklisted_tags,#user_favorite_tags,#search_post_tags_match" ); var $fields_single = $( "#c-tags #search_name_matches,#c-tag-aliases #query,#c-tag-implications #query," + @@ -184,9 +184,6 @@ case "ordfav": Danbooru.Autocomplete.user_source(term, resp, metatag); break; - case "sub": - Danbooru.Autocomplete.subscription_source(term, resp); - break; case "pool": case "-pool": case "ordpool": @@ -391,34 +388,6 @@ }); } - Danbooru.Autocomplete.subscription_source = function(term, resp) { - var match = term.match(/^(.+?):(.*)$/); - if (match) { - var user_name = match[1]; - var subscription_name = match[2]; - - $.ajax({ - url: "/tag_subscriptions.json", - data: { - "search[creator_name]": user_name, - "search[name_matches]": subscription_name + "*", - "limit": 10 - }, - method: "get", - success: function(data) { - resp($.map(data, function(subscription) { - return { - label: subscription.name.replace(/_/g, " "), - value: "sub:" + user_name + ":" + subscription.name - }; - })); - } - }); - } else { - Danbooru.Autocomplete.user_source(term, resp, "sub"); - } - } - Danbooru.Autocomplete.pool_source = function(term, resp, metatag) { $.ajax({ url: "/pools.json", diff --git a/app/controllers/tag_subscriptions_controller.rb b/app/controllers/tag_subscriptions_controller.rb index 5f2ddf4f9..6eab9c6a0 100644 --- a/app/controllers/tag_subscriptions_controller.rb +++ b/app/controllers/tag_subscriptions_controller.rb @@ -1,4 +1,5 @@ class TagSubscriptionsController < ApplicationController + before_filter :disable_feature, :only => [:create] before_filter :member_only, :only => [:new, :edit, :create, :update, :destroy, :migrate] respond_to :html, :xml, :json @@ -70,6 +71,12 @@ class TagSubscriptionsController < ApplicationController end private + def disable_feature + flash[:notice] = "Tag subscriptions are disabled" + redirect_to tag_subscriptions_path + return false + end + def check_privilege(tag_subscription) raise User::PrivilegeError unless tag_subscription.editable_by?(CurrentUser.user) end diff --git a/app/logical/daily_maintenance.rb b/app/logical/daily_maintenance.rb index 5935a0b9c..367377536 100644 --- a/app/logical/daily_maintenance.rb +++ b/app/logical/daily_maintenance.rb @@ -8,7 +8,6 @@ class DailyMaintenance Delayed::Job.delete_all(['created_at < ?', 7.days.ago]) PostVote.prune! CommentVote.prune! - #TagSubscription.process_all ApiCacheGenerator.new.generate_tag_cache PostDisapproval.prune! ForumSubscription.process_all! diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 2078de40d..fe720bfef 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -80,27 +80,6 @@ class PostQueryBuilder relation end - def add_tag_subscription_relation(subscriptions, relation) - subscriptions.each do |subscription| - if subscription =~ /^(.+?):(.+)$/ - user_name = $1 - subscription_name = $2 - user = User.find_by_name(user_name) - return relation if user.nil? - post_ids = TagSubscription.find_post_ids(user.id, subscription_name) - else - user = User.find_by_name(subscription) - return relation if user.nil? - post_ids = TagSubscription.find_post_ids(user.id) - end - - post_ids = [0] if post_ids.empty? - relation = relation.where(["posts.id IN (?)", post_ids]) - end - - relation - end - def add_saved_search_relation(saved_searches, relation) if SavedSearch.enabled? saved_searches.each do |saved_search| @@ -228,11 +207,6 @@ class PostQueryBuilder relation = relation.where("posts.pool_string != ''") end - if q[:subscriptions] - relation = add_tag_subscription_relation(q[:subscriptions], relation) - has_constraints! - end - if q[:saved_searches] relation = add_saved_search_relation(q[:saved_searches], relation) has_constraints! diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 5e2247a43..c91f31c7d 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -166,22 +166,10 @@ module PostSets [page.to_i, 1].max end - def is_tag_subscription? - tag_subscription.present? - end - def is_saved_search? tag_string =~ /search:/ end - def tag_subscription - @tag_subscription ||= tag_array.select {|x| x =~ /^sub:/}.map {|x| x.sub(/^sub:/, "")}.first - end - - def tag_subscription_tags - @tag_subscription_tags ||= TagSubscription.find_tags(tag_subscription) - end - def presenter @presenter ||= ::PostSetPresenters::Post.new(self) end diff --git a/app/logical/user_deletion.rb b/app/logical/user_deletion.rb index 0b23215a8..e7c03b392 100644 --- a/app/logical/user_deletion.rb +++ b/app/logical/user_deletion.rb @@ -22,6 +22,7 @@ class UserDeletion clear_user_settings remove_favorites clear_tag_subscriptions + clear_saved_searches rename reset_password create_mod_action @@ -37,6 +38,10 @@ private TagSubscription.where(:creator_id => user.id).destroy_all end + def clear_saved_searches + SavedSearch.where(user_id: user.id).destroy_all + end + def clear_user_settings user.email = nil user.last_logged_in_at = nil diff --git a/app/models/tag.rb b/app/models/tag.rb index f1e9a4fcf..303ad692b 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -512,10 +512,6 @@ class Tag < ActiveRecord::Base q[:tags][:related] << "fav:#{user_id}" q[:ordfav] = user_id - when "sub" - q[:subscriptions] ||= [] - q[:subscriptions] << $2 - when "search" q[:saved_searches] ||= [] q[:saved_searches] << $2 diff --git a/app/presenters/post_set_presenters/post.rb b/app/presenters/post_set_presenters/post.rb index 0b4dbd07b..f8621130f 100644 --- a/app/presenters/post_set_presenters/post.rb +++ b/app/presenters/post_set_presenters/post.rb @@ -13,8 +13,6 @@ module PostSetPresenters pattern_tags elsif post_set.is_saved_search? SavedSearch.labels_for(CurrentUser.user.id).map {|x| "search:#{x}"} - elsif post_set.is_tag_subscription? - post_set.tag_subscription_tags elsif post_set.is_single_tag? related_tags_for_single(post_set.tag_string) elsif post_set.unordered_tag_array.size == 1 diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index f1dee9467..808da1fa0 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -63,20 +63,6 @@ class UserPresenter end end - def posts_for_subscription(subscription) - arel = Post.where("id in (?)", subscription.post_id_array.map(&:to_i)).order("id desc").limit(6) - - if CurrentUser.user.hide_deleted_posts? - arel = arel.undeleted - end - - arel - end - - def tag_links_for_subscription(template, subscription) - subscription.tag_query_array.map {|x| template.link_to(x, template.posts_path(:tags => x))}.join(", ").html_safe - end - def upload_limit if user.can_upload_free? return "none" @@ -213,14 +199,6 @@ class UserPresenter template.link_to("positive:#{positive} neutral:#{neutral} negative:#{negative}", template.user_feedbacks_path(:search => {:user_id => user.id})) end - def subscriptions - if CurrentUser.user.id == user.id - user.subscriptions - else - user.subscriptions.select {|x| x.is_public?} - end - end - def saved_search_labels if CurrentUser.user.id == user.id SavedSearch.labels_for(CurrentUser.user.id) diff --git a/app/views/posts/partials/index/_related.html.erb b/app/views/posts/partials/index/_related.html.erb index 393a5719a..25c51bc1d 100644 --- a/app/views/posts/partials/index/_related.html.erb +++ b/app/views/posts/partials/index/_related.html.erb @@ -3,10 +3,6 @@