mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-24 23:06:51 +00:00
refactor(sns): remove contact post-count stats flow
This commit is contained in:
@@ -1260,10 +1260,6 @@ function registerIpcHandlers() {
|
||||
return snsService.getSnsUsernames()
|
||||
})
|
||||
|
||||
ipcMain.handle('sns:getUserPostCounts', async () => {
|
||||
return snsService.getUserPostCounts()
|
||||
})
|
||||
|
||||
ipcMain.handle('sns:getExportStats', async () => {
|
||||
return snsService.getExportStats()
|
||||
})
|
||||
|
||||
@@ -337,7 +337,6 @@ contextBridge.exposeInMainWorld('electronAPI', {
|
||||
getTimeline: (limit: number, offset: number, usernames?: string[], keyword?: string, startTime?: number, endTime?: number) =>
|
||||
ipcRenderer.invoke('sns:getTimeline', limit, offset, usernames, keyword, startTime, endTime),
|
||||
getSnsUsernames: () => ipcRenderer.invoke('sns:getSnsUsernames'),
|
||||
getUserPostCounts: () => ipcRenderer.invoke('sns:getUserPostCounts'),
|
||||
getExportStatsFast: () => ipcRenderer.invoke('sns:getExportStatsFast'),
|
||||
getExportStats: () => ipcRenderer.invoke('sns:getExportStats'),
|
||||
debugResource: (url: string) => ipcRenderer.invoke('sns:debugResource', url),
|
||||
|
||||
@@ -701,44 +701,6 @@ class SnsService {
|
||||
return { success: false, error: primary.error || fallback.error || '获取朋友圈联系人失败' }
|
||||
}
|
||||
|
||||
async getUserPostCounts(): Promise<{ success: boolean; data?: Record<string, number>; error?: string }> {
|
||||
try {
|
||||
const counts: Record<string, number> = {}
|
||||
const primary = await wcdbService.execQuery(
|
||||
'sns',
|
||||
null,
|
||||
"SELECT user_name AS username, COUNT(1) AS total FROM SnsTimeLine WHERE user_name IS NOT NULL AND user_name <> '' GROUP BY user_name"
|
||||
)
|
||||
|
||||
let rows = primary.rows
|
||||
if (!primary.success || !rows || rows.length === 0) {
|
||||
const fallback = await wcdbService.execQuery(
|
||||
'sns',
|
||||
null,
|
||||
"SELECT userName AS username, COUNT(1) AS total FROM SnsTimeLine WHERE userName IS NOT NULL AND userName <> '' GROUP BY userName"
|
||||
)
|
||||
if (!fallback.success || !fallback.rows || fallback.rows.length === 0) {
|
||||
return { success: false, error: primary.error || fallback.error || '获取朋友圈联系人条数失败' }
|
||||
}
|
||||
rows = fallback.rows
|
||||
}
|
||||
|
||||
for (const row of rows) {
|
||||
const usernameRaw = row?.username ?? row?.user_name ?? row?.userName ?? ''
|
||||
const username = typeof usernameRaw === 'string' ? usernameRaw.trim() : String(usernameRaw || '').trim()
|
||||
if (!username) continue
|
||||
const countRaw = row?.total ?? row?.count ?? row?.cnt
|
||||
const parsedCount = Number(countRaw)
|
||||
counts[username] = Number.isFinite(parsedCount) && parsedCount > 0
|
||||
? Math.floor(parsedCount)
|
||||
: this.parseCountValue(row)
|
||||
}
|
||||
return { success: true, data: counts }
|
||||
} catch (e) {
|
||||
return { success: false, error: String(e) }
|
||||
}
|
||||
}
|
||||
|
||||
private async getExportStatsFromTableCount(myWxid?: string): Promise<{ totalPosts: number; totalFriends: number; myPosts: number | null }> {
|
||||
let totalPosts = 0
|
||||
let totalFriends = 0
|
||||
|
||||
Reference in New Issue
Block a user