···
1090
1090
let repliesReceived = 0;
1091
1091
1092
1092
for (const item of feed) {
1093
1093
-
if (item && item.post) {
1094
1094
-
// Debug log with URI for tracking
1095
1095
-
console.log("Processing post metrics:", {
1093
1093
+
// Only consider posts from this author
1094
1094
+
if (item && item.post && item.post.author && item.post.author.did === did) {
1095
1095
+
// Debug log entire post structure to verify what we're accessing
1096
1096
+
console.log("Processing post structure:", JSON.stringify({
1096
1097
uri: item.post.uri,
1097
1097
-
likeCount: item.post.likeCount,
1098
1098
-
repostCount: item.post.repostCount,
1099
1099
-
quoteCount: item.post.quoteCount,
1100
1100
-
replyCount: item.post.replyCount
1101
1101
-
});
1098
1098
+
author: item.post.author.did,
1099
1099
+
metrics: {
1100
1100
+
likeCount: item.post.likeCount,
1101
1101
+
repostCount: item.post.repostCount,
1102
1102
+
quoteCount: item.post.quoteCount,
1103
1103
+
replyCount: item.post.replyCount
1104
1104
+
}
1105
1105
+
}, null, 2));
1102
1106
1103
1103
-
// Only add the direct post metrics
1104
1104
-
likesReceived += item.post.likeCount || 0;
1105
1105
-
repostsReceived += item.post.repostCount || 0;
1106
1106
-
quotesReceived += item.post.quoteCount || 0;
1107
1107
-
repliesReceived += item.post.replyCount || 0;
1107
1107
+
// Only add the direct post metrics, ignoring any nested metrics
1108
1108
+
if (item.post.likeCount !== undefined) likesReceived += item.post.likeCount;
1109
1109
+
if (item.post.repostCount !== undefined) repostsReceived += item.post.repostCount;
1110
1110
+
if (item.post.quoteCount !== undefined) quotesReceived += item.post.quoteCount;
1111
1111
+
if (item.post.replyCount !== undefined) repliesReceived += item.post.replyCount;
1108
1112
}
1109
1113
}
1110
1114
···
1118
1122
console.log("Final engagement counts (top-level only):", results);
1119
1123
return results;
1120
1124
}
1121
1121
-
1122
1125
1123
1126
/***********************************************************************
1124
1127
* Function to compute post statistics based on records and period