本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_corp_by_groupid方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_corp_by_groupid方法的具体用法?Python QueryHelper.get_corp_by_groupid怎么用?Python QueryHelper.get_corp_by_groupid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helpers.queryhelper.QueryHelper
的用法示例。
在下文中一共展示了QueryHelper.get_corp_by_groupid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: prepare_data
# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_corp_by_groupid [as 别名]
def prepare_data(self, hash_):
"""Associated with the post method.
workflow:
if get value according the hash:
return value
else:
retrieve the db and return the result.
"""
mem_key = self.get_memcache_key(hash_)
data = self.redis.getvalue(mem_key)
if data:
if isinstance(data, str):
data = eval(data)
return data[0], data[1]
start_time = int(self.get_argument('start_time', 0))
end_time = int(self.get_argument('end_time', 0))
res_ = self.db.query("SELECT id, tid, softversion,"
" owner_mobile AS umobile,"
" mobile AS tmobile, begintime, offline_time,"
" login_time, pbat, remark, group_id"
" FROM T_TERMINAL_INFO"
" WHERE service_status = 1 AND login =0"
" AND mobile like '14778%%'"
" ORDER BY offline_time DESC, pbat")
for item in res_:
item['alias'] = QueryHelper.get_alias_by_tid(
item['tid'], self.redis, self.db)
item['corp_name'] = u''
if item['group_id'] == -1:
item['user_type'] = UWEB.USER_TYPE.PERSON
#item['user_type'] = u'个人账户'
else:
item['user_type'] = UWEB.USER_TYPE.CORP
corp = QueryHelper.get_corp_by_groupid(item['group_id'], self.db)
item['corp_name'] = corp.get('name', '')
#item['user_type'] = u'集团账户'
offline_period = int(time.time()) - item['offline_time']
item['offline_period'] = offline_period if offline_period > 0 else 0
item['offline_cause'] = 2 if item['pbat'] < 5 else 1
item['remark'] = safe_unicode(item['remark'])
res = res_[:]
user_type = self.get_argument('user_type', '')
if user_type: # has no user_type
for item in res_:
if item['user_type'] != user_type:
res.remove(item)
offline_cause = self.get_argument('offline_cause', None)
if (offline_cause is not None) and (offline_cause != ''):
for item in res_:
if item['offline_cause'] != int(offline_cause):
if item in res:
res.remove(item)
offline_period = self.get_argument('offline_period', None)
if offline_period is not None:
for item in res_:
if offline_period == '1':
if item['offline_period'] >60*60*24:
if item in res:
res.remove(item)
elif offline_period == '2':
if item['offline_period'] <60*60*24*1:
if item in res:
res.remove(item)
elif offline_period == '3':
if item['offline_period'] <60*60*24*2:
if item in res:
res.remove(item)
elif offline_period == '4':
if item['offline_period'] <60*60*24*3:
if item in res:
res.remove(item)
self.redis.setvalue(mem_key,(res, [start_time, end_time]),
time=self.MEMCACHE_EXPIRY)
return res, [start_time, end_time]