コード例 #1
0
def get_not_finished_session_tasks_count(scrap_session_id: str) -> int:
    queries = [
        '''SELECT COUNT(*) FROM twint_distributed_tasks.SearchTweetScrapTasks 
        WHERE scrap_session_id=%s AND finished IS NULL''',
        '''SELECT COUNT(*) FROM twint_distributed_tasks.UserDetailsScrapTasks 
        WHERE scrap_session_id=%s AND finished IS NULL''',
        '''SELECT COUNT(*) FROM twint_distributed_tasks.UserTweetScrapTasks 
        WHERE scrap_session_id=%s AND finished IS NULL''',
        '''SELECT COUNT(*) FROM twint_distributed_tasks.UserFollowersScrapTasks 
        WHERE scrap_session_id=%s AND finished IS NULL''',
        '''SELECT COUNT(*) FROM twint_distributed_tasks.UserFollowingScrapTasks 
        WHERE scrap_session_id=%s AND finished IS NULL''',
        '''SELECT COUNT(*) FROM twint_distributed_tasks.UserFavoritesScrapTasks 
        WHERE scrap_session_id=%s AND finished IS NULL'''
    ]
    return sum([
        execute_sql_query(query, [scrap_session_id]).to_numpy()[0]
        for query in queries
    ])
コード例 #2
0
def get_all_tasks():
    return execute_sql_query(
        '''SELECT task_id, username, created, finished, queue_name, scrap_session_name
        FROM twint_distributed_tasks.UserFavoritesScrapTasks t 
            JOIN twint_distributed_tasks.ScrapSession s ON t.scrap_session_id = s.scrap_session_id''',
        [])
コード例 #3
0
def get_all_by_username(username: str):
    return execute_sql_query(
        'SELECT * FROM twint_distributed_tasks.UserFavoritesScrapTasks WHERE username=%s',
        [username])
コード例 #4
0
def get_session_id(task_id: str) -> str:
    return execute_sql_query(
        'SELECT * FROM twint_distributed_tasks.UserFavoritesScrapTasks WHERE task_id=%s',
        [task_id])['scrap_session_id'].to_numpy()[0]
コード例 #5
0
def get_task_id_sub_task_id(sub_task_id: str) -> str:
    return execute_sql_query(
        'SELECT * FROM twint_distributed_tasks.UserTweetScrapSubTasks WHERE sub_task_id=%s',
        [sub_task_id]
    )['task_id'].to_numpy()[0]
コード例 #6
0
def get_all_not_finished_sub_tasks_by_task_id(task_id: str):
    return execute_sql_query(
        'SELECT * FROM twint_distributed_tasks.UserTweetScrapSubTasks WHERE task_id=%s AND finished IS NULL',
        [task_id])
コード例 #7
0
def get_all_sessions():
    return execute_sql_query(
        'SELECT * FROM twint_distributed_tasks.ScrapSession', [])
コード例 #8
0
def get_scrap_session_name_by_id(scrap_session_name: str) -> Optional[str]:
    values = list(
        execute_sql_query(
            'SELECT * FROM twint_distributed_tasks.ScrapSession WHERE scrap_session_id=%s',
            [scrap_session_name])['scrap_session_name'].to_numpy())
    return values[0] if len(values) > 0 else None
コード例 #9
0
def get_all_tasks():
    return execute_sql_query(
        '''SELECT task_id, phrase, since, until, language, created, finished, queue_name, scrap_session_name
        FROM twint_distributed_tasks.SearchTweetScrapTasks t 
            JOIN twint_distributed_tasks.ScrapSession s ON t.scrap_session_id = s.scrap_session_id''',
        [])
コード例 #10
0
def get_all_tasks_by_username(phrase: str):
    return execute_sql_query(
        'SELECT * FROM twint_distributed_tasks.SearchTweetScrapTasks WHERE phrase=%s',
        [phrase]
    )