def cells20(): row = [None]*10 rows = [row[:] for i in range(10)] cells = Cell.all().filter('enabled =', True).order('ctime').fetch(1000) for cell in cells: rows[cell.y][cell.x] = cell return render_template('cells20.html', rows=rows, )
def update(): """ Update the global statistics. """ from models import Cell stats = get() cursor = None results = { 'total_cell_count': 0, 'active_cell_count': 0, 'initialized_cell_count': 0, 'nonemptybudget_cell_count': 0, 'total_bitcoin': 0, 'biggest_budget': 0, 'biggest_budget_cell': None, } while True: query = Cell.all() if cursor: query.with_cursor(cursor) cells = query.fetch(1000) if not cells: break cursor = query.cursor() for cell in cells: results['total_cell_count'] += 1 if cell.enabled: results['active_cell_count'] += 1 if cell.is_initialized(): results['initialized_cell_count'] += 1 if cell.bitcoin_budget: results['nonemptybudget_cell_count'] += 1 results['total_bitcoin'] += cell.bitcoin_budget if cell.bitcoin_budget > results['biggest_budget']: results['biggest_budget'] = cell.bitcoin_budget results['biggest_budget_cell'] = db.Blob(model_to_protobuf(cell)) for k,v in results.items(): setattr(stats, k, v) stats.put()
def pixels(): cells = Cell.all().filter('enabled =', True).order('-bitcoin_budget').fetch(1000) return render_template('pixels.html', cells=cells)