def set_status_by_user_date(account, date, status=None, process=None):
    """
    update user's status.

    :param account: user account
    :param date: current date by local time.
    :param status: user text input status.
    :param process: processing progress.
    :return: no
    """

    condition = "WHERE account='%s' and cur_date='%s'" % (account, date)

    update_sql = "UPDATE bot_process_status SET update_time=now()"
    if status is not None:
        update_sql = "%s , status='%s'" % (
            update_sql,
            status,
        )
    if process is not None:
        update_sql = "%s , process='%s'" % (
            update_sql,
            process,
        )

    update_sql = "%s %s" % (
        update_sql,
        condition,
    )

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(update_sql)
def insert_replace_status_by_user_date(account, date, status, process=None):
    """
    insert or update user's status.

    :param account: user account
    :param date: current date by local time.
    :param status: user text input status.
    :param process: processing progress.
    :return: Return false when status is None Else, Return None
    """

    if status is None:
        return False

    insert_sql = "INSERT INTO bot_process_status(account, cur_date, status)" \
                 " VALUES('%s', '%s', '%s') ON CONFLICT(account, cur_date) " \
                 "DO UPDATE SET status='%s', update_time=now()" % \
                 (account, date, status, status)
    if process is not None:
        insert_sql = "INSERT INTO bot_process_status(" \
                     "account, cur_date, status, process) " \
                     "VALUES('%s', '%s', '%s', '%s') " \
                     "ON CONFLICT(account, cur_date) " \
                     "DO UPDATE SET " \
                     "status='%s', process='%s', update_time=now()" % \
                     (account, date, status, process, status, process)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(insert_sql)
def delete_init_status(action):
    select_sql = "DELETE FROM system_init_status WHERE action='%s'" % (
        action, )

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
Ejemplo n.º 4
0
def clean_status_by_user(account, date):
    delete_sql = "DELETE FROM bot_process_status " \
                 "WHERE account='%s' and cur_date='%s' " % (account, date)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(delete_sql)
Ejemplo n.º 5
0
def clean_schedule_by_user(account, date):
    delete_sql = "DELETE FROM bot_calendar_record " \
                 "WHERE account='%s' and cur_date='%s'" \
                 % (account, date)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(delete_sql)
def update_init_status(action, extra):
    update_sql = "UPDATE system_init_status SET update_time=now()," \
                 "extra='%s' " \
                 "WHERE action='%s'" % (extra, action)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(update_sql)
def insert_init_status(action, extra):
    insert_sql = "INSERT INTO system_init_status(action, extra) " \
                 "VALUES('%s', '%s') ON CONFLICT(action) " \
                 "DO UPDATE SET extra='%s', update_time=now()" % \
                 (action, extra, extra)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(insert_sql)
Ejemplo n.º 8
0
def modify_schedule_by_user(schedule_id, end):
    select_sql = "UPDATE bot_calendar_record " \
                 "SET end_time=%d, update_time=now()" \
                 "WHERE schedule_id='%s'" \
                 % (end, schedule_id)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
Ejemplo n.º 9
0
def delete_status_by_user_date(account, date):
    delete_status_sql = "UPDATE bot_process_status SET status=NULL, " \
                        "update_time=now() " \
                        "WHERE account='%s' and cur_date='%s'" % \
                        (account, date)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(delete_status_sql)
Ejemplo n.º 10
0
def set_schedule_by_user(schedule_id, account, date, begin, end):
    insert_sql = "INSERT INTO bot_calendar_record(schedule_id, account, " \
                 "cur_date, begin_time, end_time) " \
                 "VALUES('%s', '%s', '%s', %d, %d)" \
                 % (schedule_id, account, date, begin, end)

    post_gre = PostGreSql()

    with post_gre as cursor:
        cursor.execute(insert_sql)
Ejemplo n.º 11
0
def get_init_status(action):
    select_sql = "SELECT extra " \
                 "FROM system_init_status WHERE action='%s'" % (action,)

    extra = None
    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
        rows = cursor.fetchall()
        if rows is not None and len(rows) == 1:
            extra = rows[0][0]
    return extra
def delete_init_status(action):
    """
    delete an item initialized data or status.

    :param action: item
    :return: no
    """

    select_sql = "DELETE FROM system_init_status WHERE action='%s'" % (
        action, )

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
Ejemplo n.º 13
0
def get_schedule_by_user(account, date):
    select_sql = "SELECT schedule_id, begin_time " \
                 "FROM bot_calendar_record " \
                 "WHERE account='%s' and cur_date='%s'" \
                 % (account, date)

    row = None
    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
        rows = cursor.fetchall()
        if rows is not None and len(rows) == 1:
            # ["schedule_id", "begin_time"]
            row = rows[0]
    return row
Ejemplo n.º 14
0
def set_status_by_user_date(account, date, status=None, process=None):

    condition = "WHERE account='%s' and cur_date='%s'" % (account, date)

    update_sql = "UPDATE bot_process_status SET update_time=now()"
    if status is not None:
        update_sql = "%s , status='%s'" % (update_sql, status,)
    if process is not None:
        update_sql = "%s , process='%s'" % (update_sql, process,)

    update_sql = "%s %s" % (update_sql, condition,)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(update_sql)
def clean_status_by_user(account, date):
    """
    delete a item.

    :param account: user account
    :param date: current date by local time.
    :return: no
    """

    delete_sql = "DELETE FROM bot_process_status " \
                 "WHERE account='%s' and cur_date='%s' " % (account, date)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(delete_sql)
Ejemplo n.º 16
0
def clean_schedule_by_user(account, date):
    """
    delete a schedule

    :param account: user account
    :param date: current date by local time.
    :return: no
    """
    delete_sql = "DELETE FROM bot_calendar_record " \
                 "WHERE account='%s' and cur_date='%s'" \
                 % (account, date)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(delete_sql)
def update_init_status(action, extra):
    """
    Update the initialization status of an item after initialization.

    :param action: Initialized item
    :param extra: Initialized data or status
    :return: no
    """

    update_sql = "UPDATE system_init_status SET update_time=now()," \
                 "extra='%s' " \
                 "WHERE action='%s'" % (extra, action)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(update_sql)
Ejemplo n.º 18
0
def modify_schedule_by_user(schedule_id, end):
    """
    update schedule's end time

    :param schedule_id: schedule_id
    :param end: schedule end time.
    :return: no
    """
    select_sql = "UPDATE bot_calendar_record " \
                 "SET end_time=%d, update_time=now()" \
                 "WHERE schedule_id='%s'" \
                 % (end, schedule_id)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
Ejemplo n.º 19
0
def get_status_by_user(account, date):

    select_sql = "SELECT status, process " \
                 "FROM bot_process_status " \
                 "WHERE account='%s' and cur_date='%s'" \
                 % (account, date)

    row = None
    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
        rows = cursor.fetchall()
        if rows is not None and len(rows) == 1:
            # ['status', 'process']
            row = rows[0]
    return row
def insert_init_status(action, extra):
    """
    Inserts the initialization status of an item after initialization.

    :param action: Initialized item
    :param extra: Initialized data or status
    :return: no
    """

    insert_sql = "INSERT INTO system_init_status(action, extra) " \
                 "VALUES('%s', '%s') ON CONFLICT(action) " \
                 "DO UPDATE SET extra='%s', update_time=now()" % \
                 (action, extra, extra)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(insert_sql)
def delete_status_by_user_date(account, date):
    """
    delete user's status.

    :param account: user account
    :param date: current date by local time.
    :return: no
    """

    delete_status_sql = "UPDATE bot_process_status SET status=NULL, " \
                        "update_time=now() " \
                        "WHERE account='%s' and cur_date='%s'" % \
                        (account, date)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(delete_status_sql)
def get_init_status(action):
    """
    Get an item initialized data or status.

    :param action: item
    :return: initialized data or status
    """

    select_sql = "SELECT extra " \
                 "FROM system_init_status WHERE action='%s'" % (action,)

    extra = None
    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
        rows = cursor.fetchall()
        if rows is not None and len(rows) == 1:
            extra = rows[0][0]
    return extra
Ejemplo n.º 23
0
def insert_replace_status_by_user_date(account, date, status, process=None):
    if status is None:
        return False

    insert_sql = "INSERT INTO bot_process_status(account, cur_date, status)" \
                 " VALUES('%s', '%s', '%s') ON CONFLICT(account, cur_date) " \
                 "DO UPDATE SET status='%s', update_time=now()" % \
                 (account, date, status, status)
    if process is not None:
        insert_sql = "INSERT INTO bot_process_status(" \
                     "account, cur_date, status, process) " \
                     "VALUES('%s', '%s', '%s', '%s') " \
                     "ON CONFLICT(account, cur_date) " \
                     "DO UPDATE SET " \
                     "status='%s', process='%s', update_time=now()" % \
                     (account, date, status, process, status, process)

    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(insert_sql)
Ejemplo n.º 24
0
def set_schedule_by_user(schedule_id, account, date, begin, end):
    """
    insert schedule

    :param schedule_id: schedule_id
    :param account: user account
    :param date: current date by local time.
    :param begin: schedule begin time.
    :param end: schedule end time.
    :return: no
    """

    insert_sql = "INSERT INTO bot_calendar_record(schedule_id, account, " \
                 "cur_date, begin_time, end_time) " \
                 "VALUES('%s', '%s', '%s', %d, %d)" \
                 % (schedule_id, account, date, begin, end)

    post_gre = PostGreSql()

    with post_gre as cursor:
        cursor.execute(insert_sql)
def get_status_by_user(account, date):
    """
    select user's status.

    :param account: user account
    :param date: current date by local time.
    :return: no
    """

    select_sql = "SELECT status, process " \
                 "FROM bot_process_status " \
                 "WHERE account='%s' and cur_date='%s'" \
                 % (account, date)

    row = None
    post_gre = PostGreSql()
    with post_gre as cursor:
        cursor.execute(select_sql)
        rows = cursor.fetchall()
        if rows is not None and len(rows) == 1:
            # ['status', 'process']
            row = rows[0]
    return row