diff --git a/backend/blueprints/spa_api/spa_api.py b/backend/blueprints/spa_api/spa_api.py index e01a342e8..6e021fa14 100644 --- a/backend/blueprints/spa_api/spa_api.py +++ b/backend/blueprints/spa_api/spa_api.py @@ -129,8 +129,8 @@ def encode_bot_name(w): @bp.route('/global/replay_count') @with_session def api_get_replay_count(session=None): - count = session.query(Game.hash).count() - return jsonify(count) + result = session.execute(Game.count_query()) + return jsonify(result.scalar()) @bp.route('/global/queue/count') diff --git a/backend/database/objects.py b/backend/database/objects.py index 9e8465cf2..c4ab59563 100644 --- a/backend/database/objects.py +++ b/backend/database/objects.py @@ -312,6 +312,9 @@ def validate_code(self, key, value): return value[:max_len] return value + def count_query(): + return "SELECT n_live_tup FROM pg_stat_all_tables WHERE relname = '%s'" % (Game.__table__.name) + class Player(DBObjectBase): __tablename__ = 'players'