Esempio n. 1
0
def do_query(text):
    query = """
        select '{text}'
    """.format(text=text, )
    print(query)
    if os.getenv('DEV'):
        print("skipping db")
        return
    return db.all(query)
Esempio n. 2
0
def do_query(user_id):
    query = """
        select '{user_id}'
    """.format(user_id=user_id, )
    print(query)
    if os.getenv('DEV'):
        print("skipping db")
        return
    return db.all(query)
Esempio n. 3
0
def do_query(user_id):
    query = """
        select ucg.id
        ,ucg.name
        from user_command_groups ucg
        where user_id = {user_id}
    """.format(user_id=user_id, )
    print(query)
    # if os.getenv('DEV'):
    #     print("skipping db")
    #     return
    return db.all(query)
Esempio n. 4
0
def do_query(user_id):
    query = """
        select a.active
        from agents a
        where a.user_id = {user_id}
    """.format(user_id=user_id, )
    print(query)
    if os.getenv('DEV'):
        print("skipping db")
        return [(True, )]
        return
    return db.all(query)
Esempio n. 5
0
def do_query(user_id, active):
    query = """
        update agents
        set active = {active}
        where user_id = {user_id}
        returning user_id, active
    """.format(user_id=user_id, active=active)
    print(query)
    if os.getenv('DEV'):
        print("skipping db")
        return
    return db.all(query)
def get_log(user_id):
    sql = """
        select command_log.id
            ,c.text
            ,command_log.executed
            ,c.audio
        from command_log
        join user_commands on user_commands.id = command_log.user_commands_id
        join commands c on c.id = user_commands.command_id
        where user_commands.user_id = {user_id}
        order by command_log.created_at desc
    """.format(user_id=user_id)
    print(sql)
    return db.all(sql)
Esempio n. 7
0
def do_query():
    query = """
        select f.id
            ,f.text
            ,f.votes
        from feedback f
        where f.label_id is null
        order by f.votes desc
            ,f.id desc
    """
    print(query)
    if os.getenv('DEV'):
        print("skipping db")
        return
    return db.all(query)
Esempio n. 8
0
def get_user(username=None):
    '''
        Gets user
    '''
    users = []  # # #
    if username is None:
        all_users = db.all('User')
        for user in all_users.values():
            users.append(return_user(user))
        return jsonify({'users': users})

    user = db.get_user(username)
    if user is None:
        return jsonify({"msg": "could not find user", "error": True})
    else:
        # # # #
        return jsonify({"user": return_user(user)})
Esempio n. 9
0
def get_active_agents():
    query = """
        -- active agents
        select a.user_id
        ,n.phone
        from agents a
        join numbers n on n.id = a.user_id
        where a.active
        and a.user_id not in (
          -- users who go messages recently
                select distinct(uc.user_id)
                from command_log cl
                join user_commands uc on uc.id = cl.user_commands_id
                where cl.created_at > now() - interval '1 hour'
        )
    """
    print(query)
    return db.all(query)
Esempio n. 10
0
    def _initListCtrl(self):
        self.LC = ListCtrl(self,
                           style=wx.LC_REPORT,
                           headings=['ID', u'BOSS名称',
                                     u'死亡时间', u'倒计时', u'刷新时间', u'状态'],
                           # columnFormat=wx.LIST_FORMAT_CENTER,
                           fgcolor='#f40',

                           )
        # ===============
        # w = h = 16
        # il = wx.ImageList(w, h)
        # il.Add(wx.Bitmap('rat_head16.ico', wx.BITMAP_TYPE_ICO))
        # self.LC.AssignImageList(il, wx.IMAGE_LIST_SMALL)
        # ===============
        self.LC.AdaptWidth(6, proportions=[0.5, 2.5, 2.5, 1, 2.5, 1])
        # ===============
        self.LC.initRows(db.all())
def list_command(user_id):
    query = """
        select
        uc.id
        ,c.text
        ,uc.enabled
        ,c.id
        from commands c
        left join (
                select *
                from user_commands uc
                where uc.user_id = {user_id}
        ) uc on uc.command_id = c.id
        order by (
                case when enabled then 1
                when enabled is null then 2
                else 3 end
        ) asc, c.text asc
    """.format(user_id=user_id)
    print(query)
    if os.getenv('DEV'):
        return
    return db.all(query)
Esempio n. 12
0
def display_all():
    data = db.all()
    ui.display_all(data=data)
Esempio n. 13
0
def display_all():
    data = db.all()
    ui.display_all(data=data)
Esempio n. 14
0
def get_blacklist():
    query = "select text, id from scrubber"
    # [('banana', 1), ('file', 2)]
    return db.all(query)