コード例 #1
0
ファイル: Users.py プロジェクト: caoxianwei/chat-2
 def getWeekData(self):
     result = Utils.db_t_d(
         dBSession.execute(
             'SELECT count(*) as n, (TO_DAYS( NOW( ) ) - TO_DAYS( from_unixtime(created_at))) as `d` FROM ht_users group by TO_DAYS( from_unixtime(created_at)) having d <= :val',
             {
                 'val': 6
             }).fetchall())
     return result
コード例 #2
0
 def getWeekData(self):
     result = []
     dataList = Utils.db_t_d(
         dBSession.execute(
             "SELECT count(*) as c, date_format(from_unixtime(add_time),'%Y-%m-%d') as d  FROM ht_admin WHERE YEARWEEK(date_format(from_unixtime(add_time),'%Y-%m-%d'),1) = YEARWEEK(now(),1) GROUP BY date_format(from_unixtime(add_time),'%Y-%m-%d');"
         ).fetchall())
     week_list = Utils.getWeekList()
     for i, week in enumerate(week_list):
         for data in dataList:
             if data['d'] == week:
                 result.append(data['c'])
                 dataList.remove(data)
                 break
         if (len(result)) <= i:
             result.append(0)
     return result