+/*
+ * Bind comment numbers(friendica_comments: Int) on each statuses page of *_timeline / favorites / search
+ *
+ * @brief Number of comments
+ *
+ * @param object $data [Status, Status]
+ *
+ * @return void
+ */
+function bindComments(&$data){
+ if(count($data) == 0) return;
+
+ $ids = [];
+ $comments = [];
+ foreach($data as $item){ $ids[] = $item['id']; }
+
+ $sql = "SELECT `parent`,COUNT(*) as comments FROM `item`
+ WHERE `parent` IN ( %s ) AND `deleted` = %d AND `gravity`= %d GROUP BY `parent`";
+ $result = q($sql, implode(",", $ids), 0, GRAVITY_COMMENT);
+
+ foreach($result as $records) {
+ $comments[$records['parent']] = $records['comments'];
+ }
+
+ foreach($data as $idx => $item){
+ $id = $item['id'];
+ $data[$idx]['friendica_comments'] = isset($comments[$id]) ? $comments[$id] : 0;
+ }
+}
+