Skip to content
Snippets Groups Projects
Commit c1e2b03e authored by Jason Salyers's avatar Jason Salyers
Browse files

[JES] Move view definition to its own file

parent 11bd9f0c
No related branches found
No related tags found
2 merge requests!456Release candidate v1 24,!370Jsalyers muting at sql level
...@@ -561,6 +561,7 @@ def setup(db): ...@@ -561,6 +561,7 @@ def setup(db):
"hive_posts_base_view.sql", "hive_posts_base_view.sql",
"hive_posts_view.sql", "hive_posts_view.sql",
"hive_votes_view.sql", "hive_votes_view.sql",
"hive_muted_accounts_view.sql",
"hive_post_operations.sql", "hive_post_operations.sql",
"head_block_time.sql", "head_block_time.sql",
"update_feed_cache.sql", "update_feed_cache.sql",
......
...@@ -14,6 +14,7 @@ for sql in postgres_handle_view_changes.sql \ ...@@ -14,6 +14,7 @@ for sql in postgres_handle_view_changes.sql \
hive_posts_base_view.sql \ hive_posts_base_view.sql \
hive_posts_view.sql \ hive_posts_view.sql \
hive_votes_view.sql \ hive_votes_view.sql \
hive_muted_accounts_view.sql \
hive_post_operations.sql \ hive_post_operations.sql \
head_block_time.sql \ head_block_time.sql \
update_feed_cache.sql \ update_feed_cache.sql \
......
DROP VIEW IF EXISTS muted_accounts_view;
CREATE OR REPLACE VIEW muted_accounts_view AS
(
SELECT observer_accounts.name AS observer, following_accounts.name AS muted
FROM hive_follows JOIN hive_accounts following_accounts ON hive_follows.following = following_accounts.id
JOIN hive_accounts observer_accounts ON hive_follows.follower = observer_accounts.id
WHERE hive_follows.state = 2
UNION
SELECT observer_accounts.name AS observer, following_accounts.name AS muted
FROM hive_follows hive_follows_direct JOIN hive_follows hive_follows_indirect ON hive_follows_direct.following = hive_follows_indirect.follower
JOIN hive_accounts following_accounts ON hive_follows_indirect.following = following_accounts.id
JOIN hive_accounts observer_accounts ON hive_follows_direct.follower = observer_accounts.id
WHERE hive_follows_direct.follow_muted AND hive_follows_indirect.state = 2
);
\ No newline at end of file
...@@ -356,21 +356,3 @@ DROP INDEX IF EXISTS hive_posts_promoted_idx; ...@@ -356,21 +356,3 @@ DROP INDEX IF EXISTS hive_posts_promoted_idx;
CREATE INDEX IF NOT EXISTS hive_posts_promoted_id_idx ON hive_posts (promoted, id) CREATE INDEX IF NOT EXISTS hive_posts_promoted_id_idx ON hive_posts (promoted, id)
WHERE NOT is_paidout AND counter_deleted = 0 WHERE NOT is_paidout AND counter_deleted = 0
; ;
DROP VIEW IF EXISTS muted_accounts_view;
CREATE OR REPLACE VIEW muted_accounts_view AS
(
SELECT observer_accounts.name AS observer, following_accounts.name AS muted
FROM hive_follows JOIN hive_accounts following_accounts ON hive_follows.following = following_accounts.id
JOIN hive_accounts observer_accounts ON hive_follows.follower = observer_accounts.id
WHERE hive_follows.state = 2
UNION
SELECT observer_accounts.name AS observer, following_accounts.name AS muted
FROM hive_follows hive_follows_direct JOIN hive_follows hive_follows_indirect ON hive_follows_direct.following = hive_follows_indirect.follower
JOIN hive_accounts following_accounts ON hive_follows_indirect.following = following_accounts.id
JOIN hive_accounts observer_accounts ON hive_follows_direct.follower = observer_accounts.id
WHERE hive_follows_direct.follow_muted AND hive_follows_indirect.state = 2
);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment