Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 127-eliminate-more-references-to-hive_posts_view
  • 221-vacuum-hivemind-tables
  • 267-rebased-onto-develop
  • 676-as-tiny-assets
  • 72-postgres-warning-about-wrong-collation-in-recursive_deps-2
  • abw_ecv_op_experiment
  • abw_max_retries
  • abw_post_delete_fix
  • abw_rshares_experiment
  • add-git-to-requirements
  • add-vote-info
  • arc-get-content-deleted
  • as-tmp-to-remove
  • asuch-limit-follows
  • asuch-postgrest-fixing-problems
  • asuch-replace-python-with-sql-get-follow-count
  • asuch-tmp-wip-condenser-get-blog
  • autoexplain-python
  • bridge_api.get_ranked_posts_fixes
  • bw_1_27_5rc8_2master
  • bw_develop-haf-rebase
  • bw_docker_supplement
  • bw_entrypoint_signal_handler_fix
  • bw_haf_compat_sync
  • bw_hafah_datasource_test
  • bw_master2develop
  • bw_mi/hivemind_wit_sa_btracker_rebase
  • bw_rebased_develop-haf
  • bw_restore_log_memory_usage_call
  • bw_simplify_blacklisted_by_observer_view
  • bw_temp_hived_source_node_verification
  • bw_update_posts_rshares_speedup
  • bw_v1_27_5_0_0_rc0
  • change-python-limits
  • cherry-pick-5dd1da34
  • cherry-pick-98eaf112
  • complete-refactor
  • db-upgrade-assert
  • deployed_20200917
  • deployed_20200928
  • deployed_20200928_pure
  • deployed_20200928_reversible_ops
  • deployed_fixes_2_develop
  • develop
  • develop-haf-backup
  • dk-benchmarks-ci-improvements
  • dk-communities-unit-tests
  • dk-get-ids-for-accounts-hotfix
  • dk-issue-3-concurrent-block-query
  • dk-list-votes-pre24
  • dk-migration-script-tags-support
  • dk-num-block-hive-feed-cache
  • dk-readme-update
  • dk-reputation_api_support
  • dk-revert-black-lists
  • dk-sql-file-list
  • dk-sql-script-executor
  • dk-sql-scripts-from-schema
  • dk-xdist-and-time
  • dn-autovacuum
  • dn-default-autovacuum
  • dn-testing
  • dn_get_block_range
  • dn_parallel_safe
  • dn_prof
  • doc-fix
  • dockerfile-update-fix
  • emf-limit-follows
  • enum_block_operations-support
  • feature/beneficiaries_communities
  • feature/hive_votes_no_index
  • feature/mute-reason-test
  • feature/mute-reason_rebase
  • feature/new_communities_type_old
  • feature/new_community_types
  • feature/role-only-if-subscribed-test1
  • fix-duplicate-pinned-posts
  • fixing-tests-with-limits
  • follow-deltas
  • follow-redesign
  • follow-redesign-speedups
  • follow-redesign-tests
  • follow_api_tests
  • get-discussion-experiment
  • hivemind_testers
  • imwatsi-first-steps
  • jes2850-decentralized-lists
  • jsalyers-add-a-cascade
  • jsalyers-fix-muting-for-reblogs
  • jsalyers-fix-muting-on-bridge-get-discussion
  • jsalyers-muting-v2
  • jsalyers-test-mute-changes
  • kbotor/backup/building-hivemind-from-other-repos
  • kbotor/building-hivemind-from-other-repos
  • kbotor/ci-rewrite-for-parallel-replay
  • km_ah_api
  • km_get_content_2_0
  • km_get_content_fill_missing2deployed
  • km_history
  • km_improved_log_gathering
  • 0.25.4
  • 1.25.0rc0
  • 1.25.2rc
  • 1.26.0
  • 1.26.1
  • 1.26.2
  • 1.26.3
  • 1.27.0.dev0
  • 1.27.10
  • 1.27.11rc1
  • 1.27.11rc2
  • 1.27.11rc3
  • 1.27.11rc4
  • 1.27.11rc5
  • 1.27.3.0.0
  • 1.27.3.0.0dev11
  • 1.27.3.0.0dev12
  • 1.27.3.0.0dev7
  • 1.27.5
  • 1.27.5.0.0rc7
  • 1.27.5rc8
  • 1.27.5rc9
  • 1.27.6rc3
  • 1.27.6rc5
  • 1.27.6rc6
  • 1.27.6rc7
  • 1.27.6rc8
  • 1.27.6rc9
  • 1.27.7rc10
  • 1.27.7rc11
  • 1.27.7rc12
  • 1.27.7rc13
  • 1.27.7rc14
  • 1.27.7rc15
  • 1.27.7rc16
  • 1.27.8
  • 1.27.9
  • Before-dk-issue-3
  • Full-sync
  • Full-sync-20200928
  • Full-sync-20201026
  • ScheduledBenchmarkTesting_18_Aug
  • env/staging-permissions
  • full_hive_sync_17_05_2021
  • git_versioning_support
  • hivemind_ci_support
  • tmp-logs
  • v1.24-RC
  • v1.24.0
  • v1.24.1
  • v1.24.1-RC
  • v1.24.2
  • v1.25.1
  • v1.25.2
  • v1.25.3
  • v1.25.4
  • v1.26.0
  • v1.27.4.0.0
  • v1.27.4.0.0dev1
  • v1.27.4.0.0dev2
160 results

Target

Select target project
  • hive/hivemind
1 result
Select Git revision
  • 127-eliminate-more-references-to-hive_posts_view
  • 221-vacuum-hivemind-tables
  • 267-rebased-onto-develop
  • 676-as-tiny-assets
  • 72-postgres-warning-about-wrong-collation-in-recursive_deps-2
  • abw_ecv_op_experiment
  • abw_max_retries
  • abw_post_delete_fix
  • abw_rshares_experiment
  • add-git-to-requirements
  • add-vote-info
  • arc-get-content-deleted
  • as-tmp-to-remove
  • asuch-limit-follows
  • asuch-postgrest-fixing-problems
  • asuch-replace-python-with-sql-get-follow-count
  • asuch-tmp-wip-condenser-get-blog
  • autoexplain-python
  • bridge_api.get_ranked_posts_fixes
  • bw_1_27_5rc8_2master
  • bw_develop-haf-rebase
  • bw_docker_supplement
  • bw_entrypoint_signal_handler_fix
  • bw_haf_compat_sync
  • bw_hafah_datasource_test
  • bw_master2develop
  • bw_mi/hivemind_wit_sa_btracker_rebase
  • bw_rebased_develop-haf
  • bw_restore_log_memory_usage_call
  • bw_simplify_blacklisted_by_observer_view
  • bw_temp_hived_source_node_verification
  • bw_update_posts_rshares_speedup
  • bw_v1_27_5_0_0_rc0
  • change-python-limits
  • cherry-pick-5dd1da34
  • cherry-pick-98eaf112
  • complete-refactor
  • db-upgrade-assert
  • deployed_20200917
  • deployed_20200928
  • deployed_20200928_pure
  • deployed_20200928_reversible_ops
  • deployed_fixes_2_develop
  • develop
  • develop-haf-backup
  • dk-benchmarks-ci-improvements
  • dk-communities-unit-tests
  • dk-get-ids-for-accounts-hotfix
  • dk-issue-3-concurrent-block-query
  • dk-list-votes-pre24
  • dk-migration-script-tags-support
  • dk-num-block-hive-feed-cache
  • dk-readme-update
  • dk-reputation_api_support
  • dk-revert-black-lists
  • dk-sql-file-list
  • dk-sql-script-executor
  • dk-sql-scripts-from-schema
  • dk-xdist-and-time
  • dn-autovacuum
  • dn-default-autovacuum
  • dn-testing
  • dn_get_block_range
  • dn_parallel_safe
  • dn_prof
  • doc-fix
  • dockerfile-update-fix
  • emf-limit-follows
  • enum_block_operations-support
  • feature/beneficiaries_communities
  • feature/hive_votes_no_index
  • feature/mute-reason-test
  • feature/mute-reason_rebase
  • feature/new_communities_type_old
  • feature/new_community_types
  • feature/role-only-if-subscribed-test1
  • fix-duplicate-pinned-posts
  • fixing-tests-with-limits
  • follow-deltas
  • follow-redesign
  • follow-redesign-speedups
  • follow-redesign-tests
  • follow_api_tests
  • get-discussion-experiment
  • hivemind_testers
  • imwatsi-first-steps
  • jes2850-decentralized-lists
  • jsalyers-add-a-cascade
  • jsalyers-fix-muting-for-reblogs
  • jsalyers-fix-muting-on-bridge-get-discussion
  • jsalyers-muting-v2
  • jsalyers-test-mute-changes
  • kbotor/backup/building-hivemind-from-other-repos
  • kbotor/building-hivemind-from-other-repos
  • kbotor/ci-rewrite-for-parallel-replay
  • km_ah_api
  • km_get_content_2_0
  • km_get_content_fill_missing2deployed
  • km_history
  • km_improved_log_gathering
  • 0.25.4
  • 1.25.0rc0
  • 1.25.2rc
  • 1.26.0
  • 1.26.1
  • 1.26.2
  • 1.26.3
  • 1.27.0.dev0
  • 1.27.10
  • 1.27.11rc1
  • 1.27.11rc2
  • 1.27.11rc3
  • 1.27.11rc4
  • 1.27.11rc5
  • 1.27.3.0.0
  • 1.27.3.0.0dev11
  • 1.27.3.0.0dev12
  • 1.27.3.0.0dev7
  • 1.27.5
  • 1.27.5.0.0rc7
  • 1.27.5rc8
  • 1.27.5rc9
  • 1.27.6rc3
  • 1.27.6rc5
  • 1.27.6rc6
  • 1.27.6rc7
  • 1.27.6rc8
  • 1.27.6rc9
  • 1.27.7rc10
  • 1.27.7rc11
  • 1.27.7rc12
  • 1.27.7rc13
  • 1.27.7rc14
  • 1.27.7rc15
  • 1.27.7rc16
  • 1.27.8
  • 1.27.9
  • Before-dk-issue-3
  • Full-sync
  • Full-sync-20200928
  • Full-sync-20201026
  • ScheduledBenchmarkTesting_18_Aug
  • env/staging-permissions
  • full_hive_sync_17_05_2021
  • git_versioning_support
  • hivemind_ci_support
  • tmp-logs
  • v1.24-RC
  • v1.24.0
  • v1.24.1
  • v1.24.1-RC
  • v1.24.2
  • v1.25.1
  • v1.25.2
  • v1.25.3
  • v1.25.4
  • v1.26.0
  • v1.27.4.0.0
  • v1.27.4.0.0dev1
  • v1.27.4.0.0dev2
160 results
Show changes
# pylint: disable=too-many-arguments,line-too-long,too-many-lines # pylint: disable=too-many-arguments,line-too-long,too-many-lines
from enum import Enum from enum import Enum
from hive.server.common.helpers import return_error_info, valid_limit, valid_account, valid_permlink from hive.server.common.helpers import return_error_info, valid_limit, valid_account, valid_permlink, valid_date
from hive.server.database_api.objects import database_post_object from hive.server.database_api.objects import database_post_object
from hive.utils.normalize import rep_to_raw, number_to_json_value, time_string_with_t from hive.utils.normalize import rep_to_raw, number_to_json_value, time_string_with_t
...@@ -20,48 +20,69 @@ async def list_comments(context, start: list, limit: int, order: str): ...@@ -20,48 +20,69 @@ async def list_comments(context, start: list, limit: int, order: str):
if order == 'by_cashout_time': if order == 'by_cashout_time':
assert len(start) == 3, "Expecting three arguments" assert len(start) == 3, "Expecting three arguments"
cashout_time = start[0] cashout_time = start[0]
valid_date(cashout_time)
if cashout_time[0:4] == '1969': if cashout_time[0:4] == '1969':
cashout_time = "infinity" cashout_time = "infinity"
author = start[1] author = start[1]
valid_account(author, allow_empty=True)
permlink = start[2] permlink = start[2]
valid_permlink(permlink, allow_empty=True)
sql = "SELECT * FROM list_comments_by_cashout_time(:cashout_time, :author, :permlink, :limit)" sql = "SELECT * FROM list_comments_by_cashout_time(:cashout_time, :author, :permlink, :limit)"
result = await db.query_all(sql, cashout_time=cashout_time, author=author, permlink=permlink, limit=limit) result = await db.query_all(sql, cashout_time=cashout_time, author=author, permlink=permlink, limit=limit)
elif order == 'by_permlink': elif order == 'by_permlink':
assert len(start) == 2, "Expecting two arguments" assert len(start) == 2, "Expecting two arguments"
author = start[0] author = start[0]
valid_account(author, allow_empty=True)
permlink = start[1] permlink = start[1]
valid_permlink(permlink, allow_empty=True)
sql = "SELECT * FROM list_comments_by_permlink(:author, :permlink, :limit)" sql = "SELECT * FROM list_comments_by_permlink(:author, :permlink, :limit)"
result = await db.query_all(sql, author=author, permlink=permlink, limit=limit) result = await db.query_all(sql, author=author, permlink=permlink, limit=limit)
elif order == 'by_root': elif order == 'by_root':
assert len(start) == 4, "Expecting 4 arguments" assert len(start) == 4, "Expecting 4 arguments"
root_author = start[0] root_author = start[0]
valid_account(root_author, allow_empty=True)
root_permlink = start[1] root_permlink = start[1]
valid_permlink(root_permlink, allow_empty=True)
start_post_author = start[2] start_post_author = start[2]
valid_account(start_post_author, allow_empty=True)
start_post_permlink = start[3] start_post_permlink = start[3]
valid_permlink(start_post_permlink, allow_empty=True)
sql = "SELECT * FROM list_comments_by_root(:root_author, :root_permlink, :start_post_author, :start_post_permlink, :limit)" sql = "SELECT * FROM list_comments_by_root(:root_author, :root_permlink, :start_post_author, :start_post_permlink, :limit)"
result = await db.query_all(sql, root_author=root_author, root_permlink=root_permlink, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit) result = await db.query_all(sql, root_author=root_author, root_permlink=root_permlink, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit)
elif order == 'by_parent': elif order == 'by_parent':
assert len(start) == 4, "Expecting 4 arguments" assert len(start) == 4, "Expecting 4 arguments"
parent_author = start[0] parent_author = start[0]
valid_account(parent_author, allow_empty=True)
parent_permlink = start[1] parent_permlink = start[1]
valid_permlink(parent_permlink, allow_empty=True)
start_post_author = start[2] start_post_author = start[2]
valid_account(start_post_author, allow_empty=True)
start_post_permlink = start[3] start_post_permlink = start[3]
valid_permlink(start_post_permlink, allow_empty=True)
sql = "SELECT * FROM list_comments_by_parent(:parent_author, :parent_permlink, :start_post_author, :start_post_permlink, :limit)" sql = "SELECT * FROM list_comments_by_parent(:parent_author, :parent_permlink, :start_post_author, :start_post_permlink, :limit)"
result = await db.query_all(sql, parent_author=parent_author, parent_permlink=parent_permlink, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit) result = await db.query_all(sql, parent_author=parent_author, parent_permlink=parent_permlink, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit)
elif order == 'by_last_update': elif order == 'by_last_update':
assert len(start) == 4, "Expecting 4 arguments" assert len(start) == 4, "Expecting 4 arguments"
parent_author = start[0] parent_author = start[0]
valid_account(parent_author, allow_empty=True)
updated_at = start[1] updated_at = start[1]
valid_date(updated_at)
start_post_author = start[2] start_post_author = start[2]
valid_account(start_post_author, allow_empty=True)
start_post_permlink = start[3] start_post_permlink = start[3]
valid_permlink(start_post_permlink, allow_empty=True)
sql = "SELECT * FROM list_comments_by_last_update(:parent_author, :updated_at, :start_post_author, :start_post_permlink, :limit)" sql = "SELECT * FROM list_comments_by_last_update(:parent_author, :updated_at, :start_post_author, :start_post_permlink, :limit)"
result = await db.query_all(sql, parent_author=parent_author, updated_at=updated_at, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit) result = await db.query_all(sql, parent_author=parent_author, updated_at=updated_at, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit)
elif order == 'by_author_last_update': elif order == 'by_author_last_update':
assert len(start) == 4, "Expecting 4 arguments" assert len(start) == 4, "Expecting 4 arguments"
author = start[0] author = start[0]
valid_account(author, allow_empty=True)
updated_at = start[1] updated_at = start[1]
valid_date(updated_at)
start_post_author = start[2] start_post_author = start[2]
valid_account(start_post_author, allow_empty=True)
start_post_permlink = start[3] start_post_permlink = start[3]
valid_permlink(start_post_permlink, allow_empty=True)
sql = "SELECT * FROM list_comments_by_author_last_update(:author, :updated_at, :start_post_author, :start_post_permlink, :limit)" sql = "SELECT * FROM list_comments_by_author_last_update(:author, :updated_at, :start_post_author, :start_post_permlink, :limit)"
result = await db.query_all(sql, author=author, updated_at=updated_at, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit) result = await db.query_all(sql, author=author, updated_at=updated_at, start_post_author=start_post_author, start_post_permlink=start_post_permlink, limit=limit)
......
...@@ -10,7 +10,7 @@ async def accounts_by_name(db, names, observer=None, lite=True): ...@@ -10,7 +10,7 @@ async def accounts_by_name(db, names, observer=None, lite=True):
"""Find and return accounts by `name`.""" """Find and return accounts by `name`."""
sql = """SELECT id, name, display_name, about, created_at, sql = """SELECT id, name, display_name, about, created_at,
vote_weight, rank, followers, following %s rank, followers, following %s
FROM hive_accounts WHERE name IN :names""" FROM hive_accounts WHERE name IN :names"""
fields = '' if lite else ', location, website, profile_image, cover_image' fields = '' if lite else ', location, website, profile_image, cover_image'
rows = await db.query_all(sql % fields, names=tuple(names)) rows = await db.query_all(sql % fields, names=tuple(names))
...@@ -21,7 +21,6 @@ async def accounts_by_name(db, names, observer=None, lite=True): ...@@ -21,7 +21,6 @@ async def accounts_by_name(db, names, observer=None, lite=True):
'id': row['id'], 'id': row['id'],
'name': row['name'], 'name': row['name'],
'created': str(row['created_at']).split(' ')[0], 'created': str(row['created_at']).split(' ')[0],
'sp': int(estimated_sp(row['vote_weight'])),
'rank': row['rank'], 'rank': row['rank'],
'followers': row['followers'], 'followers': row['followers'],
'following': row['following'], 'following': row['following'],
......
...@@ -29,6 +29,7 @@ UNIT_NAI = { ...@@ -29,6 +29,7 @@ UNIT_NAI = {
# convert special chars into their octal formats recognized by sql # convert special chars into their octal formats recognized by sql
SPECIAL_CHARS = { SPECIAL_CHARS = {
"\x00" : " ", # nul char cannot be stored in string column (ABW: if we ever find the need to store nul chars we'll need bytea, not text)
"\r" : "\\015", "\r" : "\\015",
"\n" : "\\012", "\n" : "\\012",
"\v" : "\\013", "\v" : "\\013",
...@@ -74,21 +75,26 @@ def escape_characters(text): ...@@ -74,21 +75,26 @@ def escape_characters(text):
ret = "E'" ret = "E'"
for ch in text: for ch in text:
if ch.isprintable() or ch in SPECIAL_CHARS: if ch in SPECIAL_CHARS:
try: dw = SPECIAL_CHARS[ch]
dw = SPECIAL_CHARS[ch] ret = ret + dw
ret = ret + dw
except KeyError:
ret = ret + ch
else: else:
ordinal = ord(ch) ordinal = ord(ch)
if ordinal == 0 or ordinal >= 0x80: if ordinal <= 0x80 and ch.isprintable():
escaped_value = 'u' + hex(ordinal)[2:] ret = ret + ch
# logging.info("Encoded unicode escape: {}".format(escaped_value))
else: else:
escaped_value = ch.encode('unicode-escape').decode('utf-8') hexstr = hex(ordinal)[2:]
i = len(hexstr)
ret = ret + escaped_value max = 4
escaped_value = '\\u'
if i > max:
max = 8
escaped_value = '\\U'
while i < max:
escaped_value += '0'
i += 1
escaped_value += hexstr
ret = ret + escaped_value
ret = ret + "'" ret = ret + "'"
return ret return ret
......
Subproject commit c673b555aa055358e0f5a1e1401a4110f7f83ca3 Subproject commit 9f6058b31adec6378ead1b15ae6c1e7bb75823f7