Drop post updates table.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
7
db/migrate/20190829052629_drop_post_updates.rb
Normal file
7
db/migrate/20190829052629_drop_post_updates.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require_relative "20160820003534_create_post_updates"
|
||||
|
||||
class DropPostUpdates < ActiveRecord::Migration[6.0]
|
||||
def change
|
||||
revert CreatePostUpdates
|
||||
end
|
||||
end
|
||||
@@ -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');
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user