当前位置: 首页>>代码示例>>Python>>正文


Python DB.resetCounter方法代码示例

本文整理汇总了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()
开发者ID:gordonfierce,项目名称:amphetype,代码行数:58,代码来源:Performance.py


注:本文中的Data.DB.resetCounter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。