def rebuild_membics_block(pct, pgid): logging.info("rebuild_membics_block " + pct + " " + str(pgid)) acc = None pco = None if pct == "coop": pco = coop.Coop.get_by_id(int(pgid)) if pco and pco.preb and not coop.prebuilt_membics_stale(pco): return pco.preb elif pct == "pen": pco = pen.PenName.get_by_id(int(pgid)) if pco: pen.filter_sensitive_fields(pco) if not pco: logging.info("rmb " + pct + " " + str(pgid) + " not found") return None where = "WHERE ctmid = 0 AND penid = :1 ORDER BY modified DESC" if pct == "coop": where = "WHERE ctmid = :1 ORDER BY modified DESC" vq = VizQuery(rev.Review, where, pco.key().id()) fsz = 100 # 11/30/16 complaint that 50 makes "recent" tab feel lossy fmax = fsz if pct == "coop": fmax = 500 jstr = "" js2 = "" membics = vq.fetch(fmax, read_policy=db.EVENTUAL_CONSISTENCY, deadline=60) idx = 0 # idx not initialized if enumerate punts due to no membics... for idx, membic in enumerate(membics): if idx < fsz: jstr = rev.append_review_jsoncsv(jstr, membic) else: js2 = rev.append_review_jsoncsv(js2, membic) jstr = append_top20_membics_to_jsoncsv(jstr, membics, pct, pco, 450 * 1024) if jstr: jstr = "," + jstr; jstr = moracct.obj2JSON(pco) + jstr; if pct == "coop": pco.preb = "[" + jstr + "]" pco.preb2 = "[" + js2 + "]" coop.update_coop_stats(pco, idx) # rebuild preb to include updated stats, maybe s1 off by one but ok. pco.preb = "[" + jstr + "]" mctr.synchronized_db_write(pco) return "[" + jstr + "]"
def set_db_prof_inst(self, dbprofinst): self.publicprofinst = json.loads(obj2JSON(dbprofinst)) if dbprofinst.__class__.__name__ == "PenName": pen.filter_sensitive_fields(self.publicprofinst)