def calc(self, id=0, data=None): table = PluginTable() table.connect() id = int(id) avg = self.calcAvg() if id > 0: data = table.findById(id) if data: score = self.gradePlugin(data, avg) table.updateScore(id, score) return score rows=table.query(None, None, 0) for row in rows: score = self.gradePlugin(row, avg) table.updateScore(row['id'], score) return len(rows)