29 lines
888 B
Python
29 lines
888 B
Python
import os
|
|
import sys
|
|
import paramiko
|
|
|
|
pw = os.environ["DEPLOY_PASSWORD"]
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect("20.191.152.26", username="wakka", password=pw, timeout=30)
|
|
|
|
script = r"""
|
|
sudo docker exec guest-chat-postgres-1 psql -U postgres -d chatwoot_production -c "
|
|
SELECT m.id, m.conversation_id, m.message_type, m.sender_type, left(m.content,50) AS content, m.created_at
|
|
FROM messages m
|
|
WHERE m.content LIKE '%特平尾%' OR m.conversation_id >= 4
|
|
ORDER BY m.id DESC LIMIT 20;
|
|
"
|
|
|
|
sudo docker exec guest-chat-postgres-1 psql -U postgres -d chatwoot_production -c "
|
|
SELECT c.id, c.display_id, c.status, count(m.id) AS msgs
|
|
FROM conversations c
|
|
LEFT JOIN messages m ON m.conversation_id = c.id
|
|
GROUP BY c.id ORDER BY c.id DESC LIMIT 6;
|
|
"
|
|
"""
|
|
|
|
_, o, e = c.exec_command(script, timeout=60)
|
|
sys.stdout.buffer.write(o.read())
|
|
c.close()
|