本文整理汇总了Python中Data.DB.resetCounter方法的典型用法代码示例。如果您正苦于以下问题:Python DB.resetCounter方法的具体用法?Python DB.resetCounter怎么用?Python DB.resetCounter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.DB
的用法示例。
在下文中一共展示了DB.resetCounter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: updateData
# 需要导入模块: from Data import DB [as 别名]
# 或者: from Data.DB import resetCounter [as 别名]
def updateData(self, *args):
if self.editflag:
return
where = []
if self.cb_source.currentIndex() <= 0:
pass
elif self.cb_source.currentIndex() == 1: # last text
where.append(
"r.text_id = (select text_id from result order by w desc limit 1)"
)
elif self.cb_source.currentIndex() == 2: # all texts
where.append("s.discount is null")
elif self.cb_source.currentIndex() == 3: # all lessons texts
where.append("s.discount is not null")
else:
s = self.cb_source.itemData(self.cb_source.currentIndex())
where.append("r.source = %d" % s.toInt()[0])
if len(where) > 0:
where = "where " + " and ".join(where)
else:
where = ""
g = Settings.get("perf_group_by")
if g == 0: # no grouping
sql = """select text_id,w,s.name,wpm,100.0*accuracy,viscosity
from result as r left join source as s on (r.source = s.rowid)
%s %s
order by w desc limit %d"""
elif g:
sql = """select agg_first(text_id),avg(r.w) as w,count(r.rowid) || ' result(s)',agg_median(r.wpm),
100.0*agg_median(r.accuracy),agg_median(r.viscosity)
from result as r left join source as s on (r.source = s.rowid)
%s %s
order by w desc limit %d"""
group = ""
if g == 1: # by Settings.get('def_group_by')
DB.resetCounter()
gn = Settings.get("def_group_by")
if gn <= 1:
gn = 1
group = "group by cast(counter()/%d as int)" % gn
elif g == 2: # by sitting
mis = Settings.get("minutes_in_sitting") * 60.0
DB.resetTimeGroup()
group = "group by time_group(%f, r.w)" % mis
elif g == 3: # by day
group = "group by cast((r.w+4*3600)/86400 as int)"
n = Settings.get("perf_items")
sql = sql % (where, group, n)
self.model.setData(map(list, DB.fetchall(sql)))
self.updateGraph()