mirror of
https://github.com/hicccc77/WeFlow.git
synced 2026-03-25 07:16:51 +00:00
fix(sns): fallback to userName when user_name count is zero
This commit is contained in:
@@ -881,15 +881,15 @@ class SnsService {
|
|||||||
`SELECT COUNT(1) AS total FROM SnsTimeLine WHERE user_name = '${escapedUsername}'`
|
`SELECT COUNT(1) AS total FROM SnsTimeLine WHERE user_name = '${escapedUsername}'`
|
||||||
)
|
)
|
||||||
|
|
||||||
if (primaryResult.success) {
|
const primaryTotal = (primaryResult.success && primaryResult.rows && primaryResult.rows.length > 0)
|
||||||
const totalPosts = primaryResult.rows && primaryResult.rows.length > 0
|
? this.parseCountValue(primaryResult.rows[0])
|
||||||
? this.parseCountValue(primaryResult.rows[0])
|
: 0
|
||||||
: 0
|
if (primaryResult.success && primaryTotal > 0) {
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
username: normalizedUsername,
|
username: normalizedUsername,
|
||||||
totalPosts
|
totalPosts: primaryTotal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -901,14 +901,24 @@ class SnsService {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (fallbackResult.success) {
|
if (fallbackResult.success) {
|
||||||
const totalPosts = fallbackResult.rows && fallbackResult.rows.length > 0
|
const fallbackTotal = fallbackResult.rows && fallbackResult.rows.length > 0
|
||||||
? this.parseCountValue(fallbackResult.rows[0])
|
? this.parseCountValue(fallbackResult.rows[0])
|
||||||
: 0
|
: 0
|
||||||
return {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
data: {
|
data: {
|
||||||
username: normalizedUsername,
|
username: normalizedUsername,
|
||||||
totalPosts
|
totalPosts: Math.max(primaryTotal, fallbackTotal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (primaryResult.success) {
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
data: {
|
||||||
|
username: normalizedUsername,
|
||||||
|
totalPosts: primaryTotal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user