diff --git a/hive/db/schema.py b/hive/db/schema.py index 16cc7331e9939047ef6467c8118ea51b3f778abc..282a96f0d6c0f3d901480b62d3ff2d5ab4d3335f 100644 --- a/hive/db/schema.py +++ b/hive/db/schema.py @@ -604,9 +604,6 @@ def setup(db): "condenser_get_by_feed_with_reblog.sql", "condenser_get_by_blog.sql", "bridge_get_account_posts_by_blog.sql", - "condenser_get_follow_counts.sql", - "condenser_get_names_by_followers.sql", - "condenser_get_names_by_following.sql", "condenser_get_names_by_reblogged.sql", "condenser_get_discussions_by_comments.sql", "condenser_get_account_reputations.sql" diff --git a/hive/db/sql_scripts/condenser_get_follow_counts.sql b/hive/db/sql_scripts/condenser_get_follow_counts.sql deleted file mode 100644 index b6db581b5842c595ff8b04cc5070e12c838b4b63..0000000000000000000000000000000000000000 --- a/hive/db/sql_scripts/condenser_get_follow_counts.sql +++ /dev/null @@ -1,20 +0,0 @@ -DROP FUNCTION IF EXISTS condenser_get_follow_counts; - -CREATE FUNCTION condenser_get_follow_counts( in _account VARCHAR ) -RETURNS TABLE( - following hive_accounts.following%TYPE, - followers hive_accounts.followers%TYPE -) -AS -$function$ -DECLARE -BEGIN - - RETURN QUERY SELECT - ha.following, ha.followers - FROM hive_accounts ha - WHERE ha.name = _account; - -END -$function$ -language plpgsql STABLE; diff --git a/hive/db/sql_scripts/condenser_get_names_by_followers.sql b/hive/db/sql_scripts/condenser_get_names_by_followers.sql deleted file mode 100644 index 530a06c5c6550ceb22d43cca608a969c8587002c..0000000000000000000000000000000000000000 --- a/hive/db/sql_scripts/condenser_get_names_by_followers.sql +++ /dev/null @@ -1,38 +0,0 @@ -DROP FUNCTION IF EXISTS condenser_get_names_by_followers; - -CREATE FUNCTION condenser_get_names_by_followers( in _account VARCHAR, in _start_account VARCHAR, in _state SMALLINT, _limit SMALLINT ) -RETURNS TABLE( - names hive_accounts.name%TYPE -) -AS -$function$ -DECLARE - __account_id INT := find_account_id( _account, True ); - __start_account_id INT := 0; - __created_at TIMESTAMP; -BEGIN - - IF _start_account <> '' THEN - __start_account_id = find_account_id( _start_account, True ); - END IF; - - IF __start_account_id <> 0 THEN - SELECT hf.created_at - INTO __created_at - FROM hive_follows hf - WHERE hf.following = __account_id AND hf.follower = __start_account_id; - END IF; - - RETURN QUERY SELECT - name - FROM hive_follows hf - LEFT JOIN hive_accounts ha ON hf.follower = ha.id - WHERE hf.following = __account_id - AND state = _state - AND ( __start_account_id = 0 OR hf.created_at <= __created_at ) - ORDER BY hf.created_at DESC - LIMIT _limit; - -END -$function$ -language plpgsql STABLE; diff --git a/hive/db/sql_scripts/condenser_get_names_by_following.sql b/hive/db/sql_scripts/condenser_get_names_by_following.sql deleted file mode 100644 index 1b7f48a00e6f6532ce016185899622938060162c..0000000000000000000000000000000000000000 --- a/hive/db/sql_scripts/condenser_get_names_by_following.sql +++ /dev/null @@ -1,38 +0,0 @@ -DROP FUNCTION IF EXISTS condenser_get_names_by_following; - -CREATE FUNCTION condenser_get_names_by_following( in _account VARCHAR, in _start_account VARCHAR, in _state SMALLINT, _limit SMALLINT ) -RETURNS TABLE( - names hive_accounts.name%TYPE -) -AS -$function$ -DECLARE - __account_id INT := find_account_id( _account, True ); - __start_account_id INT := 0; - __created_at TIMESTAMP; -BEGIN - - IF _start_account <> '' THEN - __start_account_id = find_account_id( _start_account, True ); - END IF; - - IF __start_account_id <> 0 THEN - SELECT hf.created_at - INTO __created_at - FROM hive_follows hf - WHERE hf.follower = __account_id AND hf.following = __start_account_id; - END IF; - - RETURN QUERY SELECT - name - FROM hive_follows hf - LEFT JOIN hive_accounts ha ON hf.following = ha.id - WHERE hf.follower = __account_id - AND state = _state - AND ( __start_account_id = 0 OR hf.created_at <= __created_at ) - ORDER BY hf.created_at DESC - LIMIT _limit; - -END -$function$ -language plpgsql STABLE; diff --git a/hive/db/sql_scripts/db_upgrade.sh b/hive/db/sql_scripts/db_upgrade.sh index 0bb9b175945e852fda8d4bfa5c59d717bd113689..f88a769c622f83d501424d99230b333955cb194a 100755 --- a/hive/db/sql_scripts/db_upgrade.sh +++ b/hive/db/sql_scripts/db_upgrade.sh @@ -41,14 +41,10 @@ for sql in postgres_handle_view_changes.sql \ condenser_api_post_ex_type.sql \ condenser_get_blog.sql \ condenser_get_content.sql \ - condenser_get_discussions_by_created.sql \ condenser_get_discussions_by_blog.sql \ + condenser_tags.sql \ + condenser_follows.sql \ hot_and_trends.sql \ - condenser_get_discussions_by_trending.sql \ - condenser_get_discussions_by_hot.sql \ - condenser_get_discussions_by_promoted.sql \ - condenser_get_post_discussions_by_payout.sql \ - condenser_get_comment_discussions_by_payout.sql \ update_hive_posts_children_count.sql \ update_hive_posts_api_helper.sql \ database_api_list_comments.sql \ @@ -61,14 +57,13 @@ for sql in postgres_handle_view_changes.sql \ condenser_get_by_feed_with_reblog.sql \ condenser_get_by_blog.sql \ bridge_get_account_posts_by_blog.sql \ - condenser_get_follow_counts.sql \ - condenser_get_names_by_followers.sql \ - condenser_get_names_by_following.sql \ - condenser_get_names_by_reblogged.sql + condenser_get_names_by_reblogged.sql \ + condenser_get_discussions_by_comments.sql \ + condenser_get_account_reputations.sql do - echo Executing psql -U $1 -d $2 -f $sql - time psql -1 -v "ON_ERROR_STOP=1" -U $1 -d $2 -c '\timing' -f $sql 2>&1 | tee -a -i upgrade.log + echo Executing psql -U $1 -d $2 -f $sql + time psql -1 -v "ON_ERROR_STOP=1" -U $1 -d $2 -c '\timing' -f $sql 2>&1 | tee -a -i upgrade.log echo $? done