diff --git a/app/models/post.rb b/app/models/post.rb index 507a13374..e53ff2f99 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -38,7 +38,6 @@ class Post < ApplicationRecord after_commit :delete_files, :on => :destroy after_commit :remove_iqdb_async, :on => :destroy after_commit :update_iqdb_async, :on => :create - after_commit :notify_pubsub belongs_to :updater, :class_name => "User", optional: true # this is handled in versions belongs_to :approver, class_name: "User", optional: true @@ -1417,12 +1416,6 @@ class Post < ApplicationRecord revert_to(target) save! end - - def notify_pubsub - return unless Danbooru.config.google_api_project - - # PostUpdate.insert(id) - end end module NoteMethods @@ -1885,16 +1878,4 @@ class Post < ApplicationRecord save end - - def update_column(name, value) - ret = super(name, value) - notify_pubsub - ret - end - - def update_columns(attributes) - ret = super(attributes) - notify_pubsub - ret - end end diff --git a/app/models/post_update.rb b/app/models/post_update.rb deleted file mode 100644 index c755b06b1..000000000 --- a/app/models/post_update.rb +++ /dev/null @@ -1,23 +0,0 @@ -class PostUpdate - def self.insert(post_id) - ActiveRecord::Base.execute_sql("insert into post_updates (post_id) values (?)", post_id) - end - - def self.get - ActiveRecord::Base.select_values_sql("delete from post_updates returning post_id").uniq - end - - def self.push - return unless Danbooru.config.google_api_project - - pubsub = Google::Apis::PubsubV1::PubsubService.new - pubsub.authorization = Google::Auth.get_application_default([Google::Apis::PubsubV1::AUTH_PUBSUB]) - topic = "projects/#{Danbooru.config.google_api_project}/topics/post_updates" - post_ids = get() - - post_ids.in_groups_of(1_000, false).each do |group| - request = Google::Apis::PubsubV1::PublishRequest.new(messages: group.map {|x| Google::Apis::PubsubV1::Message.new(data: x.to_s)}) - pubsub.publish_topic(topic, request) - end - end -end diff --git a/db/migrate/20190829052629_drop_post_updates.rb b/db/migrate/20190829052629_drop_post_updates.rb new file mode 100644 index 000000000..bbaf71e60 --- /dev/null +++ b/db/migrate/20190829052629_drop_post_updates.rb @@ -0,0 +1,7 @@ +require_relative "20160820003534_create_post_updates" + +class DropPostUpdates < ActiveRecord::Migration[6.0] + def change + revert CreatePostUpdates + end +end diff --git a/db/structure.sql b/db/structure.sql index 8a41ce92f..fc403b707 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -2593,15 +2593,6 @@ CREATE SEQUENCE public.post_replacements_id_seq ALTER SEQUENCE public.post_replacements_id_seq OWNED BY public.post_replacements.id; --- --- Name: post_updates; Type: TABLE; Schema: public; Owner: - --- - -CREATE UNLOGGED TABLE public.post_updates ( - post_id integer -); - - -- -- Name: post_votes; Type: TABLE; Schema: public; Owner: - -- @@ -7335,6 +7326,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20190827014726'), ('20190827233235'), ('20190827234625'), -('20190828005453'); +('20190828005453'), +('20190829052629');