mirror of
https://github.com/moebooru/moebooru
synced 2025-08-22 09:57:31 +00:00
Add index for post warehousing tasks
This commit is contained in:
parent
7e30845bc2
commit
b6e61fc2b0
@ -137,6 +137,7 @@ class PostFrames < ApplicationRecord
|
|||||||
# Warehouse frames. Only frames which are created and finalized will be warehoused.
|
# Warehouse frames. Only frames which are created and finalized will be warehoused.
|
||||||
def self.warehouse_frames(update_status = nil)
|
def self.warehouse_frames(update_status = nil)
|
||||||
# Find a post with frames that need warehousing.
|
# Find a post with frames that need warehousing.
|
||||||
|
# This SQL is designed to use the post_frames_for_warehouse.
|
||||||
post = Post.find_by("frames = frames_pending AND frames <> '' AND NOT frames_warehoused")
|
post = Post.find_by("frames = frames_pending AND frames <> '' AND NOT frames_warehoused")
|
||||||
return false if post.nil?
|
return false if post.nil?
|
||||||
|
|
||||||
|
7
db/migrate/20201103140508_add_post_warehouse_index.rb
Normal file
7
db/migrate/20201103140508_add_post_warehouse_index.rb
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
class AddPostWarehouseIndex < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
add_index :posts, :id,
|
||||||
|
name: 'post_frames_for_warehouse',
|
||||||
|
where: "frames = frames_pending AND frames <> '' AND NOT frames_warehoused"
|
||||||
|
end
|
||||||
|
end
|
@ -2639,6 +2639,13 @@ CREATE INDEX pools_posts_post_id_idx ON public.pools_posts USING btree (post_id)
|
|||||||
CREATE INDEX pools_user_id_idx ON public.pools USING btree (user_id);
|
CREATE INDEX pools_user_id_idx ON public.pools USING btree (user_id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: post_frames_for_warehouse; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX post_frames_for_warehouse ON public.posts USING btree (id) WHERE ((frames = frames_pending) AND (frames <> ''::text) AND (NOT frames_warehoused));
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: post_frames_out_of_date; Type: INDEX; Schema: public; Owner: -
|
-- Name: post_frames_out_of_date; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
@ -3400,6 +3407,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
|||||||
('20190817070727'),
|
('20190817070727'),
|
||||||
('20191110172526'),
|
('20191110172526'),
|
||||||
('20200908180652'),
|
('20200908180652'),
|
||||||
|
('20201103140508'),
|
||||||
('21'),
|
('21'),
|
||||||
('22'),
|
('22'),
|
||||||
('23'),
|
('23'),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user