def sync(): cs = CollectionStats(mw.col) cs.wholeCollection = True lims = [] num = 365 chunk = 1 if num is not None: lims.append("id > %d" % ( (cs.col.sched.dayCutoff-(num*chunk*86400))*1000)) lim = cs._revlogLimit() if lim: lims.append(lim) if lims: lim = "where " + " and ".join(lims) else: lim = "" if cs.type == 0: tf = 60.0 # minutes else: tf = 3600.0 # hours revlog = cs.col.db.all(""" select (cast((id/1000.0 - :cut) / 86400.0 as int))/:chunk as day, sum(time)/1000, sum(case when type = 0 then 1 else 0 end), -- lrn count sum(case when type = 1 and lastIvl < 21 then 1 else 0 end), -- yng count sum(case when type = 1 and lastIvl >= 21 then 1 else 0 end), -- mtr count sum(case when type = 2 then 1 else 0 end), -- lapse count sum(case when type = 3 then 1 else 0 end), -- cram count sum(case when type = 0 then time/1000.0 else 0 end)/:tf, -- lrn time -- yng + mtr time sum(case when type = 1 and lastIvl < 21 then time/1000.0 else 0 end)/:tf, sum(case when type = 1 and lastIvl >= 21 then time/1000.0 else 0 end)/:tf, sum(case when type = 2 then time/1000.0 else 0 end)/:tf, -- lapse time sum(case when type = 3 then time/1000.0 else 0 end)/:tf -- cram time from revlog %s group by day order by day""" % lim, cut=cs.col.sched.dayCutoff, tf=tf, chunk=chunk) values = {'data': revlog, 'email': mw.pm.profile.get('syncUser')} html = http_post(values) showInfo(html)
def _update(self): if not self.dock or not self.dock.isVisible(): return if freezeMode and self.type>10: return card = mw.reviewer.card txt = _("No Current Card") if self.type<-10: txt = _("No Last Card") card = mw.reviewer.lastCard() cs = CollectionStats(mw.col) cs.wholeCollection=True if self.type<0 else False if self.type==0: #review count txt = "<center>%s</center>" % mw.reviewer._remaining() if mw.state=="review" else '? + ? + ?' elif abs(self.type)==1: #todayStats txt = "<center>%s</center>" % cs.todayStats() elif abs(self.type)==2: #forecast chart #no filtered decks did=mw.col.decks.selected() dyn=mw.col.decks.get(did) if dyn['dyn'] and self.type>0: txt="No data for filtered decks" elif ANKI21: p=mw.mediaServer.getPort() txt = """ <script src="http://localhost:%d/_anki/jquery.js"></script> <script src="http://localhost:%d/_anki/plot.js"></script> <center>%s</center> """ % (p,p,self.dueGraph(cs)) else: txt = "<script>%s\n</script><center>%s</center>" % ( anki.js.jquery+anki.js.plot, self.dueGraph(cs)) elif abs(self.type)>=90: txt = self.customViews(card) elif mw.state!='review' and self.type>10: txt = _("No Review Card") elif card: #left or right col cs = CardStats(mw.col, card) if abs(self.type)==12: #card rev log txt = self._revlogData(card, cs) else: #card stats txt = self.deckOptionsInfo(card) txt += _("<h3>Card Stats:</h3>") txt += self.mini_card_stats(card) txt += cs.report() did = card.odid if card.odid else card.did fdid = card.did if card.odid else 0 deckName = mw.col.decks.get(did)['name'] #in case of filtered decks sis=[i for i in mw.col.db.list("select id from cards where nid=?", card.nid)] tags=mw.col.getNote(card.nid).stringTags() txt += """<table width="100%%"><tr> <td><b>Deck ID:</b></td> <td>%d</td></tr><tr> <td><b>Fil DID:</b></td> <td>%d</td></tr><tr> <td><b>oDeck:</b></td> <td>%s</td></tr><tr> <td><b>SiblingCnt:</b></td> <td>%d</td></tr><tr> <td><b>Siblings:</b></td> <td>%s</td></tr><tr> <td><b>Tags:</b></td> <td>%s</td> </tr></table>""" % (did, fdid, deckName, len(sis), str(sis), tags) style = self._style() self.web.setHtml(""" <!doctype html><html><head><style>%s</style></head> <body class="night_mode">%s</body></html>""" % (style, txt))