From cd41a563a16bf009e3cf586d0a5ef24ace7a3728 Mon Sep 17 00:00:00 2001 From: icy Date: Tue, 4 Nov 2025 15:58:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20PostgreSQL=20data=20viewing=20uti?= =?UTF-8?q?lity=20script=20-=20Create=20view=5Fpg=5Fdata.sh=20for=20easy?= =?UTF-8?q?=20database=20data=20inspection=20-=20Display=20table=20record?= =?UTF-8?q?=20counts,=20AI=20models,=20exchanges,=20and=20system=20config?= =?UTF-8?q?=20-=20Include=20beta=20codes=20and=20user=20statistics=20-=20A?= =?UTF-8?q?uto-detect=20docker-compose=20vs=20docker=20compose=20commands?= =?UTF-8?q?=20=F0=9F=A4=96=20Generated=20with=20[Claude=20Code](https://cl?= =?UTF-8?q?aude.ai/code)=20Co-Authored-By:=20tinkle-community=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- view_pg_data.sh | 65 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 view_pg_data.sh diff --git a/view_pg_data.sh b/view_pg_data.sh new file mode 100755 index 00000000..59a7aef5 --- /dev/null +++ b/view_pg_data.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# PostgreSQL数据查看工具 +echo "🔍 PostgreSQL 数据查看工具" +echo "==========================" + +# 检测Docker Compose命令 +DOCKER_COMPOSE_CMD="" +if command -v "docker-compose" &> /dev/null; then + DOCKER_COMPOSE_CMD="docker-compose" +elif command -v "docker" &> /dev/null && docker compose version &> /dev/null; then + DOCKER_COMPOSE_CMD="docker compose" +else + echo "❌ 错误:找不到 docker-compose 或 docker compose 命令" + exit 1 +fi + +echo "📊 数据库概览:" +$DOCKER_COMPOSE_CMD exec postgres psql -U nofx -d nofx --pset pager=off -c " +SELECT relname as \"表名\", n_live_tup as \"记录数\" +FROM pg_stat_user_tables +WHERE n_live_tup > 0 +ORDER BY relname; +" + +echo -e "\n🤖 AI模型配置:" +$DOCKER_COMPOSE_CMD exec postgres psql -U nofx -d nofx --pset pager=off -c " +SELECT id, name, provider, enabled, + CASE WHEN api_key != '' THEN '已配置' ELSE '未配置' END as api_key_status +FROM ai_models ORDER BY id; +" + +echo -e "\n🏢 交易所配置:" +$DOCKER_COMPOSE_CMD exec postgres psql -U nofx -d nofx --pset pager=off -c " +SELECT id, name, type, enabled, + CASE WHEN api_key != '' THEN '已配置' ELSE '未配置' END as api_key_status +FROM exchanges ORDER BY id; +" + +echo -e "\n⚙️ 关键系统配置:" +$DOCKER_COMPOSE_CMD exec postgres psql -U nofx -d nofx --pset pager=off -c " +SELECT key, + CASE + WHEN LENGTH(value) > 50 THEN LEFT(value, 50) || '...' + ELSE value + END as value +FROM system_config +WHERE key IN ('admin_mode', 'beta_mode', 'api_server_port', 'default_coins', 'jwt_secret') +ORDER BY key; +" + +echo -e "\n🎟️ 内测码统计:" +$DOCKER_COMPOSE_CMD exec postgres psql -U nofx -d nofx --pset pager=off -c " +SELECT + CASE WHEN used THEN '已使用' ELSE '未使用' END as status, + COUNT(*) as count +FROM beta_codes +GROUP BY used +ORDER BY used; +" + +echo -e "\n👥 用户信息:" +$DOCKER_COMPOSE_CMD exec postgres psql -U nofx -d nofx --pset pager=off -c " +SELECT id, email, otp_verified, created_at FROM users ORDER BY created_at; +" \ No newline at end of file