Touches up get_channel function & minor touchup to query
This commit is contained in:
parent
ee26f3e913
commit
96220c2501
3 changed files with 8 additions and 10 deletions
|
@ -38,8 +38,9 @@ CREATE TABLE IF NOT EXISTS CHANNEL(
|
|||
-- DROP INDEX IF EXISTS COMMENT_CLAIM_INDEX;
|
||||
CREATE INDEX IF NOT EXISTS CLAIM_COMMENT_INDEX ON COMMENT (LbryClaimId, CommentId);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS CHANNEL_COMMENT_INDEX ON COMMENT (ChannelId, CommentId);
|
||||
|
||||
DROP INDEX CHANNEL_COMMENT_INDEX;
|
||||
CREATE INDEX IF NOT EXISTS CHANNEL_COMMENT_INDEX ON COMMENT(ChannelId, CommentId)
|
||||
;
|
||||
|
||||
-- VIEWS
|
||||
DROP VIEW IF EXISTS COMMENTS_ON_CLAIMS;
|
||||
|
|
|
@ -170,13 +170,10 @@ def insert_channel(conn: sqlite3.Connection, channel_name: str, channel_id: str)
|
|||
)
|
||||
|
||||
|
||||
def get_channel_from_comment_id(conn: sqlite3.Connection, comment_id: str):
|
||||
def get_channel_id_from_comment_id(conn: sqlite3.Connection, comment_id: str):
|
||||
with conn:
|
||||
channel = conn.execute("""
|
||||
SELECT CHN.ClaimId AS channel_id, CHN.Name AS channel_name
|
||||
FROM CHANNEL AS CHN, COMMENT AS CMT
|
||||
WHERE CHN.ClaimId = CMT.ChannelId AND CMT.CommentId = ?
|
||||
LIMIT 1
|
||||
SELECT channel_id, channel_name FROM COMMENTS_ON_CLAIMS WHERE comment_id = ?
|
||||
""", (comment_id,)
|
||||
).fetchone()
|
||||
return dict(channel) if channel else dict()
|
||||
|
|
|
@ -9,7 +9,7 @@ from asyncio import coroutine
|
|||
from misc import clean_input_params
|
||||
from src.database import get_claim_comments
|
||||
from src.database import get_comments_by_id, get_comment_ids
|
||||
from src.database import get_channel_from_comment_id
|
||||
from src.database import get_channel_id_from_comment_id
|
||||
from src.database import obtain_connection
|
||||
from src.database import delete_comment_by_id
|
||||
from src.writes import create_comment_or_error
|
||||
|
@ -26,7 +26,7 @@ def ping(*args):
|
|||
|
||||
def handle_get_channel_from_comment_id(app, kwargs: dict):
|
||||
with obtain_connection(app['db_path']) as conn:
|
||||
return get_channel_from_comment_id(conn, **kwargs)
|
||||
return get_channel_id_from_comment_id(conn, **kwargs)
|
||||
|
||||
|
||||
def handle_get_comment_ids(app, kwargs):
|
||||
|
|
Loading…
Reference in a new issue