remove uniqueness constraint on postupdates
This commit is contained in:
@@ -1383,7 +1383,7 @@ class Post < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def notify_pubsub
|
def notify_pubsub
|
||||||
return unless Danbooru.config.google_api_project
|
#return unless Danbooru.config.google_api_project
|
||||||
|
|
||||||
PostUpdate.insert(id)
|
PostUpdate.insert(id)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
class PostUpdate
|
class PostUpdate
|
||||||
def self.insert(post_id)
|
def self.insert(post_id)
|
||||||
ActiveRecord::Base.execute_sql("insert into post_updates (post_id) values (?)", post_id)
|
ActiveRecord::Base.execute_sql("insert into post_updates (post_id) values (?)", post_id)
|
||||||
rescue ActiveRecord::RecordNotUnique
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get
|
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
|
end
|
||||||
|
|
||||||
def self.push
|
def self.push
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
$.post("<%= Danbooru.config.report_server %>/hits", {
|
$.post("<%= Danbooru.config.report_server %>/hits", {
|
||||||
key: "<%= key %>",
|
key: "<%= key %>",
|
||||||
value: "<%= value %>",
|
value: "<%= value %>",
|
||||||
uid: <%= CurrentUser.user.id.to_s %>,
|
<% if CurrentUser.user.is_platinum? %>
|
||||||
|
uid: <%= CurrentUser.user.id %>,
|
||||||
|
<% end %>
|
||||||
sig: "<%= sig %>"
|
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);
|
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: -
|
-- 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 ('20160820003534');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20160822230752');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user