| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- import Parse from 'parse/node.js';
- Parse.initialize('lami-ai');
- Parse.serverURL = 'https://server.sh-lami.com/parse';
- Parse.masterKey = process.env.PARSE_MASTER_KEY || '5s1gfOasPqx9JKsA';
- const CHAT = [0, 2, 6, 13, 14, 15, 16, 20, 22, 23, 29, 41, 78, 123, 141, 146, 213];
- const q = new Parse.Query('Message');
- q.containedIn('msgType', CHAT);
- q.notEqualTo('roomId', null);
- q.limit(1000);
- q.descending('timestamp');
- const msgs = await q.find({ useMasterKey: true });
- const byRoom = new Map();
- for (const m of msgs) {
- const roomId = m.get('roomId');
- if (!roomId) continue;
- if (!byRoom.has(roomId)) byRoom.set(roomId, { chat: 0, total: 0, samples: [] });
- const e = byRoom.get(roomId);
- e.chat++;
- const content = String(m.get('content') || '').slice(0, 100);
- const sender = m.get('senderName') || m.get('senderId') || '';
- const ts = m.get('timestamp');
- if (e.samples.length < 3) e.samples.push({ msgType: m.get('msgType'), sender, content, ts });
- }
- const qAll = new Parse.Query('Message');
- qAll.notEqualTo('roomId', null);
- qAll.limit(1000);
- const allMsgs = await qAll.find({ useMasterKey: true });
- for (const m of allMsgs) {
- const roomId = m.get('roomId');
- if (!roomId) continue;
- if (!byRoom.has(roomId)) byRoom.set(roomId, { chat: 0, total: 0, samples: [] });
- byRoom.get(roomId).total++;
- }
- const roomIds = [...byRoom.keys()];
- const gq = new Parse.Query('GroupChat');
- gq.containedIn('roomId', roomIds);
- gq.limit(500);
- const groups = await gq.find({ useMasterKey: true });
- const nameMap = new Map(groups.map((g) => [g.get('roomId'), g.get('name') || g.get('roomName') || '']));
- const rows = [...byRoom.entries()]
- .map(([roomId, v]) => ({ roomId, name: nameMap.get(roomId) || '(无名)', ...v }))
- .sort((a, b) => b.chat - a.chat);
- console.log('=== 有聊天记录的群 ===');
- const withChat = rows.filter((r) => r.chat > 0);
- console.log(`共 ${withChat.length} 个群有聊天消息\n`);
- for (const r of withChat.slice(0, 25)) {
- console.log('---');
- console.log(`群名: ${r.name}`);
- console.log(`roomId: ${r.roomId}`);
- console.log(`聊天 ${r.chat} 条 / 全部 ${r.total} 条`);
- for (const s of r.samples) {
- console.log(` [${s.msgType}] ${s.sender}: ${s.content}`);
- }
- }
- console.log('\n=== 只有撤回/系统消息、无聊天文字的群 (前10) ===');
- for (const r of rows.filter((x) => x.chat === 0 && x.total > 0).slice(0, 10)) {
- console.log(`${r.name || '(无名)'} | ${r.roomId} | 共 ${r.total} 条非聊天`);
- }
|