From ba158dfeb1eec1025c1af163077b1dd44238ea5c Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 8 Nov 2015 15:33:12 +0100 Subject: [PATCH 1/3] Include per-group count of unseen items in /ping output See #1718 Unfinished work --- mod/ping.php | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/mod/ping.php b/mod/ping.php index 791ceed35..a1648f835 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -33,6 +33,7 @@ function ping_init(&$a) { $home = 0; $network = 0; + $network_group = array(); $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`, `item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, @@ -84,6 +85,25 @@ function ping_init(&$a) { } } + if ( $network ) + { + # Find out how unseen network posts are spread across groups + $sql = "SELECT g.id, g.name, count(i.id) gm + FROM `group` g, group_member gm, item i + WHERE g.uid = %d + AND i.uid = %d + AND i.unseen AND i.visible + AND NOT i.deleted + AND i.`contact-id` = gm.`contact-id` + AND gm.gid = g.id GROUP BY g.id"; + #echo '' . $sql . ''; + $r = q(sql, intval(local_user()), intval(local_user())); + #echo $r; + foreach ($r as $it) { + $network_group[] = $it; + } + } + $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`, `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo` FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id` @@ -202,6 +222,13 @@ function ping_init(&$a) { $network $home\r\n"; if ($register!=0) echo "$register"; + if ( count($network_group) ) { + echo ''; + foreach ($network_group as $it) { + echo '' . $it['count'] . ""; + } + echo ""; + } echo "$all_events $all_events_today From e28072f548f9a66061928b3f6feb2cde5c1614f6 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 8 Nov 2015 15:56:08 +0100 Subject: [PATCH 2/3] Fix bugs and rename to --- mod/ping.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/mod/ping.php b/mod/ping.php index a1648f835..0b5e1c4c9 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -88,20 +88,17 @@ function ping_init(&$a) { if ( $network ) { # Find out how unseen network posts are spread across groups - $sql = "SELECT g.id, g.name, count(i.id) gm - FROM `group` g, group_member gm, item i - WHERE g.uid = %d - AND i.uid = %d - AND i.unseen AND i.visible - AND NOT i.deleted - AND i.`contact-id` = gm.`contact-id` - AND gm.gid = g.id GROUP BY g.id"; + $sql = "SELECT g.id, g.name, count(i.id) count " . + "FROM `group` g, group_member gm, item i " . + "WHERE g.uid = %d " . + "AND i.uid = %d " . + "AND i.unseen AND i.visible " . + "AND NOT i.deleted " . + "AND i.`contact-id` = gm.`contact-id` " . + "AND gm.gid = g.id GROUP BY g.id"; #echo '' . $sql . ''; - $r = q(sql, intval(local_user()), intval(local_user())); - #echo $r; - foreach ($r as $it) { - $network_group[] = $it; - } + $network_group = q($sql, intval(local_user()), intval(local_user())); + #echo ''; } $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`, @@ -223,11 +220,11 @@ function ping_init(&$a) { $home\r\n"; if ($register!=0) echo "$register"; if ( count($network_group) ) { - echo ''; + echo ''; foreach ($network_group as $it) { echo '' . $it['count'] . ""; } - echo ""; + echo ""; } echo "$all_events From d31c3723766ccc93ba28e23b6a3c8ee1e21e76c8 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sun, 8 Nov 2015 15:56:43 +0100 Subject: [PATCH 3/3] Revert the rename of --- mod/ping.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mod/ping.php b/mod/ping.php index 0b5e1c4c9..a7a2755c5 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -220,11 +220,11 @@ function ping_init(&$a) { $home\r\n"; if ($register!=0) echo "$register"; if ( count($network_group) ) { - echo ''; + echo ''; foreach ($network_group as $it) { echo '' . $it['count'] . ""; } - echo ""; + echo ""; } echo "$all_events