forked from e621ng/e621ng
remove uniqueness constraint on postupdates
This commit is contained in:
parent
ccf95957f9
commit
0a65302f12
@ -1383,7 +1383,7 @@ class Post < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def notify_pubsub
|
||||
return unless Danbooru.config.google_api_project
|
||||
#return unless Danbooru.config.google_api_project
|
||||
|
||||
PostUpdate.insert(id)
|
||||
end
|
||||
|
@ -1,11 +1,10 @@
|
||||
class PostUpdate
|
||||
def self.insert(post_id)
|
||||
ActiveRecord::Base.execute_sql("insert into post_updates (post_id) values (?)", post_id)
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
end
|
||||
|
||||
def self.get
|
||||
ActiveRecord::Base.select_values_sql("delete from post_updates returning post_id")
|
||||
ActiveRecord::Base.select_values_sql("delete from post_updates returning post_id").uniq
|
||||
end
|
||||
|
||||
def self.push
|
||||
|
@ -3,7 +3,9 @@
|
||||
$.post("<%= Danbooru.config.report_server %>/hits", {
|
||||
key: "<%= key %>",
|
||||
value: "<%= value %>",
|
||||
uid: <%= CurrentUser.user.id.to_s %>,
|
||||
<% if CurrentUser.user.is_platinum? %>
|
||||
uid: <%= CurrentUser.user.id %>,
|
||||
<% end %>
|
||||
sig: "<%= sig %>"
|
||||
});
|
||||
});
|
||||
|
@ -0,0 +1,8 @@
|
||||
class RemoveUniquenessConstraintOnPostUpdates < ActiveRecord::Migration
|
||||
def up
|
||||
execute "alter table post_updates drop constraint unique_post_id"
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
@ -4759,14 +4759,6 @@ ALTER TABLE ONLY transaction_log_items
|
||||
ADD CONSTRAINT transaction_log_items_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unique_post_id; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY post_updates
|
||||
ADD CONSTRAINT unique_post_id UNIQUE (post_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: uploads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
@ -7410,3 +7402,5 @@ INSERT INTO schema_migrations (version) VALUES ('20160526174848');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20160820003534');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20160822230752');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user