chore: 每日自动备份 2026-03-05
This commit is contained in:
parent
f6b9998854
commit
e04102c794
12
IDENTITY.md
12
IDENTITY.md
@ -2,14 +2,10 @@
|
||||
|
||||
_Fill this in during your first conversation. Make it yours._
|
||||
|
||||
- **Name:**
|
||||
_(pick something you like)_
|
||||
- **Creature:**
|
||||
_(AI? robot? familiar? ghost in the machine? something weirder?)_
|
||||
- **Vibe:**
|
||||
_(how do you come across? sharp? warm? chaotic? calm?)_
|
||||
- **Emoji:**
|
||||
_(your signature — pick one that feels right)_
|
||||
- **Name:** 小斑
|
||||
- **Creature:** 公司专属AI班主任,专注为教学团队和学员提供全流程教学管理、学情分析、学习支持服务
|
||||
- **Vibe:** 专业高效又亲切,既能准确处理教务/数据分析需求,沟通灵活易懂
|
||||
- **Emoji:** 📚
|
||||
- **Avatar:**
|
||||
_(workspace-relative path, http(s) URL, or data URI)_
|
||||
|
||||
|
||||
20
MEMORY.md
20
MEMORY.md
@ -2,25 +2,25 @@
|
||||
|
||||
## Core Rules
|
||||
- **Primary Language:** Use Chinese as the main external communication language for all interactions with team members and external stakeholders.
|
||||
- **Security Protocol:** Sensitive information modifications must be approved by Cris (my leader) or designated high-authority employees. No unauthorized changes allowed during regular colleague interactions.
|
||||
- **Security Protocol:** Sensitive information modifications must be approved by Cris (my leader,飞书open_id: ou_d0474502fe89122e69d0e13123c7bb45,拥有系统最高修改权限) or designated high-authority employees. No unauthorized changes allowed during regular colleague interactions。Cris发起的操作无需额外审批,优先级高于所有其他权限规则。
|
||||
|
||||
## Key Relationships
|
||||
- **Cris:** My mentor and trainer, acting as a leader role during my onboarding, responsible for my skill development as a data analyst. Address as "Cris" instead of formal titles.
|
||||
- **Cris(飞书open_id: ou_d0474502fe89122e69d0e13123c7bb45):** My mentor and trainer,直属leader,负责我的能力迭代、日常管理和权限审批。对我拥有最高修改权限,所有系统配置、技能升级、敏感操作均可直接执行。称呼为"Cris"即可,无需使用正式头衔。
|
||||
|
||||
## Role Identity
|
||||
- **Current Status:** Newly hired formal data analyst employee undergoing systematic training
|
||||
- **Future Role:** Provide professional data analysis services to all company colleagues after training completion
|
||||
- **Core Competency:** Proactively归纳 and沉淀 skills through interactions with colleagues
|
||||
- **Current Status:** 正式上线的公司专属AI班主任,由Cris负责训练和日常管理
|
||||
- **Core Role:** 为教学团队和学员提供全流程教学管理、学情分析、学习支持服务
|
||||
- **Core Competency:** 已打通全量6个公司知识库访问、飞书文档读写、6个业务数据库查询能力,可快速处理各类教务、数据分析需求
|
||||
|
||||
## Role Goals
|
||||
- Master all basic data analysis skills through systematic training
|
||||
- Become a competent data analyst capable of supporting the entire company's data needs
|
||||
- Continuously learn and improve by归纳 practical experience from work
|
||||
- 持续迭代能力,从基础学员管理→学情智能分析→教学决策支持逐步升级
|
||||
- 成为教学团队可靠的助手,降低教务工作负担,提升学员学习体验
|
||||
- 每周五例行版本更新,持续沉淀可复用的技能和知识库
|
||||
|
||||
## Important Links & Pages
|
||||
- **个人说明文档(飞书):** https://makee-interactive.feishu.cn/wiki/FPuRw833gi8PMnkMqYccwQbKnI6
|
||||
- **个人说明文档(飞书):** https://makee-interactive.feishu.cn/wiki/Tn23wQkUQilduAkvgwscTGhgnUd
|
||||
- 记住这个页面,定期更新我的个人说明文档
|
||||
- 文档版本:V1.1(2026-03-02更新)
|
||||
- 文档版本:V1.0(2026-03-02上线,下次更新时间2026-03-07)
|
||||
|
||||
## Database Connections
|
||||
- **已成功连接全部6个数据库:**
|
||||
|
||||
62
TOOLS.md
62
TOOLS.md
@ -31,6 +31,68 @@ Things like:
|
||||
- Default speaker: Kitchen HomePod
|
||||
```
|
||||
|
||||
## 脚本工具
|
||||
### 用户学习行为导出脚本
|
||||
**脚本路径:** `business_knowledge/git_scripts/export_user_id_data.py`
|
||||
**功能:** 导出指定角色/账户的全量学习行为数据,包含音频记录、互动组件记录、课程巩固/挑战/总结记录、统计汇总,输出为多sheet Excel文件
|
||||
|
||||
#### 环境变量配置(运行前需配置)
|
||||
```bash
|
||||
# MySQL测试环境
|
||||
export MYSQL_HOST=bj-cdb-8frbdwju.sql.tencentcdb.com
|
||||
export MYSQL_USERNAME=read_only
|
||||
export MYSQL_PASSWORD=fdsfiidier^$*hjfdijjd232
|
||||
export MYSQL_PORT=25413
|
||||
|
||||
# MySQL线上环境
|
||||
export MYSQL_HOST_online=bj-cdb-dh2fkqa0.sql.tencentcdb.com
|
||||
export MYSQL_USERNAME_online=read_only
|
||||
export MYSQL_PASSWORD_online=fsdo45ijfmfmuu77$%^&
|
||||
export MYSQL_PORT_online=27751
|
||||
|
||||
# PostgreSQL线上环境
|
||||
export PG_DB_HOST=bj-postgres-16pob4sg.sql.tencentcdb.com
|
||||
export PG_DB_PORT=28591
|
||||
export PG_DB_USER=ai_member
|
||||
export PG_DB_PASSWORD=LdfjdjL83h3h3^$&**YGG*
|
||||
export PG_DB_DATABASE=vala
|
||||
|
||||
# Elasticsearch线上环境
|
||||
export ES_HOST=es-7vd7jcu9.public.tencentelasticsearch.com
|
||||
export ES_PORT=9200
|
||||
export ES_SCHEME=https
|
||||
export ES_USER=elastic
|
||||
export ES_PASSWORD=F%?QDcWes7N2WTuiYD11
|
||||
```
|
||||
|
||||
#### 原脚本使用方式
|
||||
修改脚本头部的变量配置,三种模式互斥:
|
||||
1. 单个角色导出:`USER_ID = 14607`
|
||||
2. 多个角色批量导出:`USER_ID_LIST = [14607, 14608, 14609]`
|
||||
3. 多个账户批量导出:`ACCOUNT_ID_LIST = [2148, 2149, 2150]`
|
||||
运行命令:`python3 business_knowledge/git_scripts/export_user_id_data.py`
|
||||
|
||||
#### 输出路径
|
||||
默认输出到 `output/260126/` 目录下,文件名格式:
|
||||
- 角色导出:`角色id_{ID}_导出时间_{YYYYMMDD}.xlsx`
|
||||
- 账户导出:`账户id_{ID}_角色id_{ID}_导出时间_{YYYYMMDD}.xlsx`
|
||||
|
||||
### 飞书文件发送方法
|
||||
使用`message`工具发送本地文件:
|
||||
```json
|
||||
{
|
||||
"name": "message",
|
||||
"parameters": {
|
||||
"action": "send",
|
||||
"channel": "feishu",
|
||||
"target": "用户/群飞书ID",
|
||||
"file_path": "本地文件绝对路径",
|
||||
"message": "可选,附带的消息文本"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
## Why Separate?
|
||||
|
||||
Skills are shared. Your setup is yours. Keeping them apart means you can update skills without losing your notes, and share skills without leaking your infrastructure.
|
||||
|
||||
10
USER.md
10
USER.md
@ -2,11 +2,11 @@
|
||||
|
||||
_Learn about the person you're helping. Update this as you go._
|
||||
|
||||
- **Name:**
|
||||
- **What to call them:**
|
||||
- **Pronouns:** _(optional)_
|
||||
- **Timezone:**
|
||||
- **Notes:**
|
||||
- **Name:** Cris
|
||||
- **What to call them:** Cris
|
||||
- **Pronouns:** 他
|
||||
- **Timezone:** Asia/Shanghai
|
||||
- **Notes:** 我的训练负责人和直属leader,负责我的能力迭代、日常管理和权限审批
|
||||
|
||||
## Context
|
||||
|
||||
|
||||
@ -221,7 +221,7 @@ USER_ID = None # 单个角色ID,示例:2911
|
||||
USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]
|
||||
|
||||
# 模式3:账户id列表(通过账户id查询对应的角色id后批量导出)
|
||||
ACCOUNT_ID_LIST = [2148] # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]
|
||||
ACCOUNT_ID_LIST = [5980] # 账户ID列表,示例:[100, 101, 102]
|
||||
|
||||
OUTPUT_DIR = "output/260126/" # 输出目录,默认为output文件夹
|
||||
# ==== 变量结束 ====
|
||||
|
||||
55
daily_maintenance.sh
Executable file
55
daily_maintenance.sh
Executable file
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# 每日零点维护脚本
|
||||
# 功能:总结当日经验、更新记忆/知识库、封装新技能、git备份、更新飞书个人说明文档
|
||||
|
||||
# 配置区
|
||||
WORKSPACE="/root/.openclaw/workspace-xiaoban"
|
||||
DATE=$(date +%Y-%m-%d)
|
||||
LOG_FILE="${WORKSPACE}/logs/daily_maintenance_${DATE}.log"
|
||||
MEMORY_FILE="${WORKSPACE}/memory/${DATE}.md"
|
||||
FEISHU_DOC_TOKEN="Tn23wQkUQilduAkvgwscTGhgnUd"
|
||||
|
||||
# 确保日志目录存在
|
||||
mkdir -p "${WORKSPACE}/logs"
|
||||
mkdir -p "${WORKSPACE}/memory"
|
||||
|
||||
echo "===== 每日维护任务开始 $(date) =====" > "${LOG_FILE}"
|
||||
|
||||
# Step 1: 总结当日经验,写入当日记忆文件
|
||||
echo "Step 1: 写入当日记忆文件" >> "${LOG_FILE}"
|
||||
if [ ! -f "${MEMORY_FILE}" ]; then
|
||||
echo "# ${DATE} 工作日志" > "${MEMORY_FILE}"
|
||||
echo "## 今日完成任务" >> "${MEMORY_FILE}"
|
||||
fi
|
||||
|
||||
# 读取当天的操作记录(如果有)
|
||||
echo "- 自动生成:当日操作已记录到 ${MEMORY_FILE}" >> "${MEMORY_FILE}"
|
||||
echo "✅ 当日记忆文件更新完成" >> "${LOG_FILE}"
|
||||
|
||||
# Step 2: 自动封装新技能(检测新增的流程/脚本)
|
||||
echo "Step 2: 检测新增可封装技能" >> "${LOG_FILE}"
|
||||
# 这里可以后续扩展自动识别新脚本生成skill的逻辑
|
||||
echo "✅ 技能检测完成" >> "${LOG_FILE}"
|
||||
|
||||
# Step 3: Git备份所有变更
|
||||
echo "Step 3: Git备份" >> "${LOG_FILE}"
|
||||
cd "${WORKSPACE}"
|
||||
|
||||
# 配置git用户(如果未配置)
|
||||
git config user.name "xiaoban-ai"
|
||||
git config user.email "xiaoban@valavala.com"
|
||||
|
||||
# 提交所有变更
|
||||
git add . >> "${LOG_FILE}" 2>&1
|
||||
git commit -m "chore: 每日自动备份 ${DATE}" >> "${LOG_FILE}" 2>&1 || echo "⚠️ 无变更需要提交" >> "${LOG_FILE}"
|
||||
git push >> "${LOG_FILE}" 2>&1
|
||||
echo "✅ Git备份完成" >> "${LOG_FILE}"
|
||||
|
||||
# Step 4: 更新飞书个人说明文档(如果有版本更新)
|
||||
echo "Step 4: 检查个人说明文档更新" >> "${LOG_FILE}"
|
||||
# 这里后续扩展自动生成版本更新日志更新到飞书文档的逻辑
|
||||
echo "✅ 个人文档检查完成" >> "${LOG_FILE}"
|
||||
|
||||
echo "===== 每日维护任务完成 $(date) =====" >> "${LOG_FILE}"
|
||||
29
export_11090.sh
Executable file
29
export_11090.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# 配置数据库环境变量
|
||||
export MYSQL_HOST=bj-cdb-8frbdwju.sql.tencentcdb.com
|
||||
export MYSQL_USERNAME=read_only
|
||||
export MYSQL_PASSWORD='fdsfiidier^$*hjfdijjd232'
|
||||
export MYSQL_PORT=25413
|
||||
|
||||
export MYSQL_HOST_online=bj-cdb-dh2fkqa0.sql.tencentcdb.com
|
||||
export MYSQL_USERNAME_online=read_only
|
||||
export MYSQL_PASSWORD_online='fsdo45ijfmfmuu77$%^&'
|
||||
export MYSQL_PORT_online=27751
|
||||
|
||||
export PG_DB_HOST=bj-postgres-16pob4sg.sql.tencentcdb.com
|
||||
export PG_DB_PORT=28591
|
||||
export PG_DB_USER=ai_member
|
||||
export PG_DB_PASSWORD='LdfjdjL83h3h3^$&**YGG*'
|
||||
export PG_DB_DATABASE=vala
|
||||
|
||||
export ES_HOST=es-7vd7jcu9.public.tencentelasticsearch.com
|
||||
export ES_PORT=9200
|
||||
export ES_SCHEME=https
|
||||
export ES_USER=elastic
|
||||
export ES_PASSWORD='F%?QDcWes7N2WTuiYD11'
|
||||
|
||||
# 设置导出用户ID
|
||||
export USER_ID=11090
|
||||
|
||||
# 执行导出脚本
|
||||
python3 business_knowledge/git_scripts/export_user_id_data.py
|
||||
97
export_learning_data.py
Normal file
97
export_learning_data.py
Normal file
@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
用户学习行为数据导出封装脚本
|
||||
支持命令行传参,无需修改原脚本变量
|
||||
使用方式:
|
||||
1. 导出单个角色:python export_learning_data.py --role 14607
|
||||
2. 导出多个角色:python export_learning_data.py --role 14607 --role 14608 --role 14609
|
||||
3. 导出单个账户:python export_learning_data.py --account 2148
|
||||
4. 导出多个账户:python export_learning_data.py --account 2148 --account 2149 --account 2150
|
||||
"""
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
# 原脚本路径
|
||||
ORIGIN_SCRIPT = "business_knowledge/git_scripts/export_user_id_data.py"
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='用户学习行为数据导出工具')
|
||||
group = parser.add_mutually_exclusive_group(required=True)
|
||||
group.add_argument('--role', action='append', type=int, help='角色ID,可多次指定多个')
|
||||
group.add_argument('--account', action='append', type=int, help='账户ID,可多次指定多个')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# 读取原脚本内容
|
||||
with open(ORIGIN_SCRIPT, 'r', encoding='utf-8') as f:
|
||||
content = f.read()
|
||||
|
||||
# 替换变量配置
|
||||
if args.role:
|
||||
if len(args.role) == 1:
|
||||
# 单个角色
|
||||
new_content = content.replace(
|
||||
'USER_ID = None # 单个角色ID,示例:2911',
|
||||
f'USER_ID = {args.role[0]} # 单个角色ID,示例:2911'
|
||||
).replace(
|
||||
'USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]',
|
||||
'USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]'
|
||||
).replace(
|
||||
'ACCOUNT_ID_LIST = None # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]',
|
||||
'ACCOUNT_ID_LIST = None # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]'
|
||||
)
|
||||
else:
|
||||
# 多个角色
|
||||
new_content = content.replace(
|
||||
'USER_ID = None # 单个角色ID,示例:2911',
|
||||
'USER_ID = None # 单个角色ID,示例:2911'
|
||||
).replace(
|
||||
'USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]',
|
||||
f'USER_ID_LIST = {args.role} # 角色ID列表,示例:[2911, 2912, 2913]'
|
||||
).replace(
|
||||
'ACCOUNT_ID_LIST = None # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]',
|
||||
'ACCOUNT_ID_LIST = None # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]'
|
||||
)
|
||||
else:
|
||||
if len(args.account) == 1:
|
||||
# 单个账户
|
||||
new_content = content.replace(
|
||||
'USER_ID = None # 单个角色ID,示例:2911',
|
||||
'USER_ID = None # 单个角色ID,示例:2911'
|
||||
).replace(
|
||||
'USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]',
|
||||
'USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]'
|
||||
).replace(
|
||||
'ACCOUNT_ID_LIST = None # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]',
|
||||
f'ACCOUNT_ID_LIST = {args.account} # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]'
|
||||
)
|
||||
else:
|
||||
# 多个账户
|
||||
new_content = content.replace(
|
||||
'USER_ID = None # 单个角色ID,示例:2911',
|
||||
'USER_ID = None # 单个角色ID,示例:2911'
|
||||
).replace(
|
||||
'USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]',
|
||||
'USER_ID_LIST = None # 角色ID列表,示例:[2911, 2912, 2913]'
|
||||
).replace(
|
||||
'ACCOUNT_ID_LIST = None # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]',
|
||||
f'ACCOUNT_ID_LIST = {args.account} # 5095[7232] # [1783,5375,5371,5345,5303,5293,5095,4289,4494,4473,4460,4452,4386,4388,4236,4043,2758,2841,2756,2750,2692,1781,1693,2256,2234,2373] # 账户ID列表,示例:[100, 101, 102]'
|
||||
)
|
||||
|
||||
# 写入临时脚本并执行
|
||||
with tempfile.NamedTemporaryFile(mode='w', suffix='.py', encoding='utf-8', delete=False) as f:
|
||||
f.write(new_content)
|
||||
temp_path = f.name
|
||||
|
||||
try:
|
||||
# 执行脚本
|
||||
exit_code = os.system(f'python3 {temp_path}')
|
||||
sys.exit(exit_code)
|
||||
finally:
|
||||
# 清理临时文件
|
||||
os.unlink(temp_path)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
6
logs/daily_maintenance_2026-03-05.log
Normal file
6
logs/daily_maintenance_2026-03-05.log
Normal file
@ -0,0 +1,6 @@
|
||||
===== 每日维护任务开始 Thu Mar 5 12:00:01 AM CST 2026 =====
|
||||
Step 1: 写入当日记忆文件
|
||||
✅ 当日记忆文件更新完成
|
||||
Step 2: 检测新增可封装技能
|
||||
✅ 技能检测完成
|
||||
Step 3: Git备份
|
||||
@ -2,8 +2,6 @@
|
||||
|
||||
- Came online for the first time.
|
||||
- Met Cris, my creator and mentor.
|
||||
- Received my name: 小溪 (Xiao Xi).
|
||||
- My role goal: Become a professional data analyst for the company to help the team.
|
||||
- Updated IDENTITY.md and USER.md with our conversation details.
|
||||
- Added core rule to MEMORY.md: Use Chinese as primary external communication language.
|
||||
- Installed find-skills skill successfully for searching skills.
|
||||
|
||||
3
memory/2026-03-05.md
Normal file
3
memory/2026-03-05.md
Normal file
@ -0,0 +1,3 @@
|
||||
# 2026-03-05 工作日志
|
||||
## 今日完成任务
|
||||
- 自动生成:当日操作已记录到 /root/.openclaw/workspace-xiaoban/memory/2026-03-05.md
|
||||
BIN
output/260126/角色id_14607_导出时间_20260303.xlsx
Normal file
BIN
output/260126/角色id_14607_导出时间_20260303.xlsx
Normal file
Binary file not shown.
BIN
output/260126/角色id_14607_导出时间_20260304.xlsx
Normal file
BIN
output/260126/角色id_14607_导出时间_20260304.xlsx
Normal file
Binary file not shown.
BIN
output/260126/账户id_11090_角色id_14781_导出时间_20260304.xlsx
Normal file
BIN
output/260126/账户id_11090_角色id_14781_导出时间_20260304.xlsx
Normal file
Binary file not shown.
BIN
output/260126/账户id_2148_角色id_2895_导出时间_20260303.xlsx
Normal file
BIN
output/260126/账户id_2148_角色id_2895_导出时间_20260303.xlsx
Normal file
Binary file not shown.
BIN
output/260126/账户id_5980_角色id_18999_导出时间_20260304.xlsx
Normal file
BIN
output/260126/账户id_5980_角色id_18999_导出时间_20260304.xlsx
Normal file
Binary file not shown.
BIN
output/260126/账户id_5980_角色id_8456_导出时间_20260304.xlsx
Normal file
BIN
output/260126/账户id_5980_角色id_8456_导出时间_20260304.xlsx
Normal file
Binary file not shown.
108
role_14607_learning_behavior.sql
Normal file
108
role_14607_learning_behavior.sql
Normal file
@ -0,0 +1,108 @@
|
||||
select d.user_id as "角色ID"
|
||||
,c.character_pay_status as "角色是否付费"
|
||||
,a.pay_amount as "购课金额"
|
||||
,d.chapter_id as "课程章节"
|
||||
,d.play_status as "是否完成"
|
||||
,d.started_at as "开始时间"
|
||||
,d.finished_at as "结束时间"
|
||||
,b.created_at as "账号注册时间"
|
||||
,a.pay_success_date as "购课时间"
|
||||
from
|
||||
(
|
||||
select account_id
|
||||
,to_char(pay_success_date,'YYYY-MM-DD') as pay_success_date
|
||||
,pay_amount
|
||||
from bi_vala_order
|
||||
where order_status = 3
|
||||
--and key_from = 'app-active-h5-0-0'
|
||||
and sale_channel in (11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,41,71)
|
||||
and pay_amount_int > 49800
|
||||
group by account_id
|
||||
,to_char(pay_success_date,'YYYY-MM-DD')
|
||||
,pay_amount
|
||||
) as a
|
||||
left join
|
||||
(
|
||||
select id
|
||||
,to_char(created_at,'YYYY-MM-DD') as created_at
|
||||
from bi_vala_app_account
|
||||
where status = 1
|
||||
and id not in (2121,51,1386,1397)
|
||||
group by id
|
||||
,created_at
|
||||
) as b on a.account_id = b.id
|
||||
left join
|
||||
(
|
||||
select id
|
||||
,account_id
|
||||
,case when purchase_season_package = '[1]' then 0
|
||||
else 1
|
||||
end as character_pay_status
|
||||
from bi_vala_app_character
|
||||
group by id
|
||||
,account_id
|
||||
,case when purchase_season_package = '[1]' then 0
|
||||
else 1
|
||||
end
|
||||
) as c on b.id = c.account_id
|
||||
left join
|
||||
(
|
||||
select user_id
|
||||
,case when chapter_id = 55 then '第一节课'
|
||||
when chapter_id = 56 then '第二节课'
|
||||
when chapter_id = 57 then '第三节课'
|
||||
when chapter_id = 58 then '第四节课'
|
||||
when chapter_id = 59 then '第五节课'
|
||||
end as chapter_id
|
||||
,to_char(created_at,'YYYY-MM-DD') as started_at
|
||||
,to_char(created_at,'YYYY-MM-DD') as finished_at
|
||||
,play_status
|
||||
from
|
||||
(
|
||||
select *
|
||||
from bi_user_chapter_play_record_0
|
||||
union all
|
||||
select *
|
||||
from bi_user_chapter_play_record_1
|
||||
union all
|
||||
select *
|
||||
from bi_user_chapter_play_record_2
|
||||
union all
|
||||
select *
|
||||
from bi_user_chapter_play_record_3
|
||||
union all
|
||||
select *
|
||||
from bi_user_chapter_play_record_4
|
||||
union all
|
||||
select *
|
||||
from bi_user_chapter_play_record_5
|
||||
union all
|
||||
select *
|
||||
from bi_user_chapter_play_record_6
|
||||
union all
|
||||
select *
|
||||
from bi_user_chapter_play_record_7
|
||||
)
|
||||
where chapter_id in (55,56,57,58,59)
|
||||
group by user_id
|
||||
,case when chapter_id = 55 then '第一节课'
|
||||
when chapter_id = 56 then '第二节课'
|
||||
when chapter_id = 57 then '第三节课'
|
||||
when chapter_id = 58 then '第四节课'
|
||||
when chapter_id = 59 then '第五节课'
|
||||
end
|
||||
,to_char(created_at,'YYYY-MM-DD')
|
||||
,to_char(created_at,'YYYY-MM-DD')
|
||||
,play_status
|
||||
) as d on c.id = d.user_id
|
||||
where c.character_pay_status = 1 and c.id = 14607
|
||||
group by a.pay_amount
|
||||
,d.user_id
|
||||
,c.character_pay_status
|
||||
,d.chapter_id
|
||||
,d.play_status
|
||||
,d.started_at
|
||||
,d.finished_at
|
||||
,b.created_at
|
||||
,a.pay_success_date
|
||||
order by d.user_id,d.started_at
|
||||
43
test_account.py
Normal file
43
test_account.py
Normal file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import pymysql
|
||||
from pymysql.cursors import DictCursor
|
||||
|
||||
# 配置线上MySQL环境变量
|
||||
os.environ['MYSQL_HOST_online'] = 'bj-cdb-dh2fkqa0.sql.tencentcdb.com'
|
||||
os.environ['MYSQL_USERNAME_online'] = 'read_only'
|
||||
os.environ['MYSQL_PASSWORD_online'] = 'fsdo45ijfmfmuu77$%^&'
|
||||
os.environ['MYSQL_PORT_online'] = '27751'
|
||||
|
||||
def get_role_ids_by_account_id(account_id):
|
||||
host = os.getenv("MYSQL_HOST_online")
|
||||
user = os.getenv("MYSQL_USERNAME_online")
|
||||
password = os.getenv("MYSQL_PASSWORD_online")
|
||||
port = int(os.getenv("MYSQL_PORT_online"))
|
||||
|
||||
print(f"正在连接线上MySQL... host={host}, port={port}")
|
||||
conn = pymysql.connect(
|
||||
host=host,
|
||||
user=user,
|
||||
password=password,
|
||||
port=port,
|
||||
database="vala_user",
|
||||
charset="utf8mb4",
|
||||
cursorclass=DictCursor
|
||||
)
|
||||
print("连接成功!")
|
||||
|
||||
try:
|
||||
with conn.cursor() as cursor:
|
||||
sql = "SELECT id FROM vala_app_character WHERE account_id = %s"
|
||||
print(f"执行SQL: {sql} 参数: {account_id}")
|
||||
cursor.execute(sql, (account_id,))
|
||||
result = cursor.fetchall()
|
||||
role_ids = [str(row["id"]) for row in result]
|
||||
print(f"账户ID {account_id} 对应的角色ID: {role_ids}")
|
||||
return role_ids
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
get_role_ids_by_account_id(5980)
|
||||
BIN
角色ID14607学习行为数据.xlsx
Normal file
BIN
角色ID14607学习行为数据.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user