From da2349bb6a85d13f0aa29046bef3021cf0c884ba Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 12 Feb 2015 17:45:25 -0800 Subject: provide relief to sites that are severely impacted by the slow ITEM_UNSEEN searches. This does not incorporate any other flag optimisations as that will require a major DB update and possibly involve significant downtime. This is just to bite off a little chunk now and provide some much needed relief. --- mod/channel.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 1a471718d..788bacf70 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -147,23 +147,21 @@ function channel_content(&$a, $update = 0, $load = false) { if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND (item_flags & %d) > 0 $sql_extra limit 1", + AND (item_flags & %d) > 0 AND item_unseen = 1 $sql_extra limit 1", dbesc($mid), intval($a->profile['profile_uid']), - intval(ITEM_WALL), - intval(ITEM_UNSEEN) + intval(ITEM_WALL) ); } else { $r = q("SELECT distinct parent AS `item_id`, created from item left join abook on item.author_xchan = abook.abook_xchan WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND ( item_flags & %d ) > 0 + AND (item_flags & %d) > 0 AND item_unseen = 1 AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", intval($a->profile['profile_uid']), intval(ITEM_WALL), - intval(ITEM_UNSEEN), intval(ABOOK_FLAG_BLOCKED) ); } @@ -317,10 +315,8 @@ function channel_content(&$a, $update = 0, $load = false) { } if($is_owner && $update_unseen) { - $r = q("UPDATE item SET item_flags = (item_flags & ~%d) - WHERE (item_flags & %d) > 0 AND (item_flags & %d) > 0 AND uid = %d $update_unseen", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 + AND (item_flags & %d) > 0 AND uid = %d $update_unseen", intval(ITEM_WALL), intval(local_channel()) ); -- cgit v1.2.3 From 2c7e8bea88abd4e835645996849e16ecd62dfa35 Mon Sep 17 00:00:00 2001 From: zottel Date: Fri, 20 Feb 2015 14:07:56 +0100 Subject: show item title in channel/mid and display pages --- mod/channel.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 788bacf70..109c9a596 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -329,8 +329,11 @@ function channel_content(&$a, $update = 0, $load = false) { $o .= conversation($a,$items,'channel',$update,'traditional'); } - if((! $update) || ($_COOKIE['jsAvailable'] != 1)) + if((! $update) || ($_COOKIE['jsAvailable'] != 1)) { $o .= alt_pager($a,count($items)); + if ($mid && $items[0]['title']) + $a->page['title'] = $items[0]['title'] . " - " . $a->page['title']; + } if($mid) $o .= '
'; -- cgit v1.2.3 From 6da40fc559f540e67802f771411aa9f85dc8d64d Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 15 Mar 2015 16:48:45 -0700 Subject: mod_id: load profile so the sidebar profile will work --- mod/channel.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 109c9a596..3216da7e1 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -36,6 +36,11 @@ function channel_init(&$a) { $a->page['htmlhead'] .= '' . "\r\n" ; + +// Not yet ready for prime time +// $a->page['htmlhead'] .= '' . "\r\n" ; +// $a->page['htmlhead'] .= '' . "\r\n" ; + // Run profile_load() here to make sure the theme is set before // we start loading content -- cgit v1.2.3 From 178b768e3ce43f3c75abec1540fcdc909c8c2197 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 16 Mar 2015 17:08:50 -0700 Subject: openid cleanup --- mod/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 3216da7e1..2a0373a81 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -39,7 +39,7 @@ function channel_init(&$a) { // Not yet ready for prime time // $a->page['htmlhead'] .= '' . "\r\n" ; -// $a->page['htmlhead'] .= '' . "\r\n" ; +// $a->page['htmlhead'] .= '' . "\r\n" ; // Run profile_load() here to make sure the theme is set before // we start loading content -- cgit v1.2.3 From 63683734a21e90149c464f7e9b03e7aedc29868e Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 18 Mar 2015 19:06:05 -0700 Subject: make the channel item query match recent changes to network item query (and some slightly older changes in display item query), and allow '@' in linkified urls. --- mod/channel.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 2a0373a81..9df400cbe 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -149,17 +149,19 @@ function channel_content(&$a, $update = 0, $load = false) { $page_mode = 'client'; + $abook_uids = " and abook.abook_channel = " . intval($a->profile['profile_uid']) . " "; + if(($update) && (! $load)) { if ($mid) { - $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 + $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0 AND (item_flags & %d) > 0 AND item_unseen = 1 $sql_extra limit 1", - dbesc($mid), + dbesc($mid . '%'), intval($a->profile['profile_uid']), intval(ITEM_WALL) ); } else { $r = q("SELECT distinct parent AS `item_id`, created from item - left join abook on item.author_xchan = abook.abook_xchan + left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d AND item_restrict = 0 AND (item_flags & %d) > 0 AND item_unseen = 1 AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) -- cgit v1.2.3 From a2e3ca6fd8ba8c0630de089d772fdd668b84428b Mon Sep 17 00:00:00 2001 From: friendica Date: Sat, 21 Mar 2015 16:46:28 -0700 Subject: add loadtime search to channel and fix it for home. display and search need further investigation --- mod/channel.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 9df400cbe..3fc4a9269 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -50,6 +50,11 @@ function channel_init(&$a) { function channel_content(&$a, $update = 0, $load = false) { + + if($load) + $_SESSION['loadtime'] = datetime_convert(); + + $category = $datequery = $datequery2 = ''; $mid = ((x($_REQUEST,'mid')) ? $_REQUEST['mid'] : ''); @@ -151,10 +156,19 @@ function channel_content(&$a, $update = 0, $load = false) { $abook_uids = " and abook.abook_channel = " . intval($a->profile['profile_uid']) . " "; + $simple_update = (($update) ? " AND item_unseen = 1 " : ''); + + + if($update && $_SESSION['loadtime']) + $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + if($load) + $simple_update = ''; + + if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND item_unseen = 1 $sql_extra limit 1", + AND (item_flags & %d) > 0 $simple_update $sql_extra limit 1", dbesc($mid . '%'), intval($a->profile['profile_uid']), intval(ITEM_WALL) @@ -163,7 +177,7 @@ function channel_content(&$a, $update = 0, $load = false) { $r = q("SELECT distinct parent AS `item_id`, created from item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND item_unseen = 1 + AND (item_flags & %d) > 0 $simple_update AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", @@ -254,6 +268,9 @@ function channel_content(&$a, $update = 0, $load = false) { } + + + if((! $update) && (! $load)) { // This is ugly, but we can't pass the profile_uid through the session to the ajax updater, -- cgit v1.2.3 From 6631540d20068d3c4ee221518e8f430507662e27 Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 12:55:13 -0700 Subject: provide visual feedback when deleting a like by liking it again. --- mod/channel.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 3fc4a9269..16aac2e51 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -158,13 +158,11 @@ function channel_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); - if($update && $_SESSION['loadtime']) - $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; + $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; - if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid like '%s' and uid = %d AND item_restrict = 0 @@ -185,6 +183,7 @@ function channel_content(&$a, $update = 0, $load = false) { intval(ITEM_WALL), intval(ABOOK_FLAG_BLOCKED) ); + $_SESSION['loadtime'] = datetime_convert(); } } -- cgit v1.2.3 From 2bd19e6b51ff7331c04f23c0ab78f1e16b5a054e Mon Sep 17 00:00:00 2001 From: friendica Date: Sun, 22 Mar 2015 15:00:41 -0700 Subject: $simple_update isn't so simple any more. Make sure we don't re-itnroduce the bug that session['loadtime'] was created to fix. It's questionable whether we still need to even look for item_unseen but I won't make that call today. We can also eliminate the restriction on not doing live updates from the discover tab since we aren't relying completely on item_unseen (which can only be set by the owner and won't work on a page with virtual owners). --- mod/channel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mod/channel.php') diff --git a/mod/channel.php b/mod/channel.php index 16aac2e51..022def2a8 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -159,7 +159,7 @@ function channel_content(&$a, $update = 0, $load = false) { $simple_update = (($update) ? " AND item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) - $simple_update = " AND ( item_unseen = 1 or item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; + $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; -- cgit v1.2.3