Activity: How to make it so that the most "attractive" activity is on top

5 years 11 months ago #304821 by timstohr
Hi kyle,
In the distant past (about a year ago), I asked you if it would be possible to make it so that the post that the posts would "jump" to the top if they get commented on (eg a post that that dropped under the READ MORE fold and got newly commented on could be interesting for others as well and then it would appear for at the top of a stream).

You had mentioned that this would be too complicated to realise (cannot remember why). I had a thought about it recently and actually it is really easy. all you need to do is let the stream not sort by time stamp of the activity but by time stamp of activity + commented (most recent one is the one that counts).

That way you have an "intelligent", adaptive, interest-driven stream.

That would be a really cool feature and really drive commenting.

Please Log in to join the conversation.

5 years 11 months ago - 5 years 11 months ago #304823 by krileon
It's not that easy. What you're asking is to join the activity and comment tables then sort by both. This would cripple CB Activity performance. All my tests are done with well over 200,000 rows per table to put stress on the SQL. Activity streams are really hard to do right and be performant. In short it needs as minimal joins as possible as full table joins easily increase call times by 3x over. Subqueries due to the way they are optimized aren't as bad, but still should be minimal (only ones applied are CB Gallery and CB GroupJive when necessary). Joining comments table into activity flat out can not happen due to the amount of data.

Your issue is solved using "Activity Grouping" already built into CB Activity and by logging an activity entry when someone comments on activity, which is done by just publishing the "CB Activity - Comment" system action in CB Auto Actions. This will cause a "xyz commented on..." activity post to show up at time of the comment, which includes an insert of the activity they commented on. Example of what such activity looks like as follows (note the styling will be a little different as this is from Bootstrap 4 upgraded CB Activity).



Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Attachments:

Please Log in to join the conversation.

5 years 11 months ago #304824 by timstohr
What you proposed kind works but not really. For example, user 1 makes post 1, user comments on post 1. Then you have inside the stream directly next to each other "post 1" and then "replica-post 1" That doubles the content and superbly confuses the user. I have done the test already (although quite some time ago).

Regarding the posting, I was thinking along those lines. Activity gets a timestamp directly from post IF there are no comments. If there are comments (which have all already been found by CB activity), THEN it disregards the timestamp of the post BUT only uses the timestamp of the most recent comment.

That would not necessitate anymore SQL queries since it has already loaded all the data. It only looks in the comments that it has found to be anyway associated with the activity post....

Please Log in to join the conversation.

5 years 11 months ago #304828 by krileon

What you proposed kind works but not really. For example, user 1 makes post 1, user comments on post 1. Then you have inside the stream directly next to each other "post 1" and then "replica-post 1" That doubles the content and superbly confuses the user. I have done the test already (although quite some time ago).

Duplicates are only an issue for the original activity entry. It does this on purpose because menu access to the original activity entry is not available in an insert. That means the owner or admins wouldn't be able to edit, delete, or report the original activity. Facebook does the exact same thing, but the assumption here is that activity on the site isn't so slow that it poses a problem. It's possible in code for me to suppress duplication of the original but for the reasons listed it will continue to display.

Regarding the posting, I was thinking along those lines. Activity gets a timestamp directly from post IF there are no comments. If there are comments (which have all already been found by CB activity), THEN it disregards the timestamp of the post BUT only uses the timestamp of the most recent comment.

There is no way to do that without scanning the comments table when querying for activity, which for reasons listed in my previous reply is not going to happen.

That would not necessitate anymore SQL queries since it has already loaded all the data. It only looks in the comments that it has found to be anyway associated with the activity post....

That's not how the streams work. The activity query has no clue comments even exist. It's a fast lookup query after activity has already been loaded to see if comments exist (it's not a join or subquery in the activity query as that would hurt performance). So the activity query has no access to that information.

Worst case you just use an auto action to change the date of the original activity entry when someone comments on it and that resolves your issue. This assumes the commented on activity isn't sufficient for your needs.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

5 years 11 months ago #304832 by timstohr
Agreed the auto action would solve it the best, however I have absolutely no idea how to make it. Any help?

Also, there would be a really "easy" way to have all of the required stuff. If the timestamp for the activity posts (like in the picture below) where to be taken from another column than the timestamp of the ordering (ordering timestamp could be influenced by the Auto action you mentioned) then everything would work just perfectly.



IMPORTANT: Facebook uses the "XYZ commented on ACTIVITY-abc" way ONLY on the Newsfeed (where they have selective algorithms). Inside Groups for example (where you see all the posts one after the other as is the case with the stream, ie it is chronological), they use the timestamping method you described with the auto action and another column for the original activity timestamp.
Attachments:

Please Log in to join the conversation.

5 years 11 months ago #304852 by krileon

Agreed the auto action would solve it the best, however I have absolutely no idea how to make it. Any help?

You'll probably need to use a Code action since you need to load by a specific activity entry, which the CB Activity action can't do. Example as follows.

Global
Triggers: activity_onAfterCreateStreamComment
Type: Code
User: Automatic
Access: Everybody
Conditions
1: [cb:parse function="clean" method="int"][var1_activity][/cb:parse] Greater Than 0
Action
Method: PHP
Code:
$variables['var2']->set( 'date', '[var3_date]' );
$variables['var2']->store();

For that trigger var2 is the source object. The object being commented on (if available, but in this case we're sure it is since we're checking that the comment stream is an activity comment stream).

Also, there would be a really "easy" way to have all of the required stuff. If the timestamp for the activity posts (like in the picture below) where to be taken from another column than the timestamp of the ordering (ordering timestamp could be influenced by the Auto action you mentioned) then everything would work just perfectly.

The date output can be modified using the display triggers. Display trigger for activity entries is as follows.

implode( '', $_PLUGINS->trigger( 'activity_onDisplayStreamActivity', array( &$row, &$title, &$date, &$message, &$insert, &$footer, &$menu, $stream, $output ) ) );

Note var3 can be used to prefix, suffix, or entirely replace the date display of an activity entry as it is passed by reference. Using a Code action and having set Variable 3 as a reference under the Parameters tab you'd be able to modify it to whatever you want.

IMPORTANT: Facebook uses the "XYZ commented on ACTIVITY-abc" way ONLY on the Newsfeed (where they have selective algorithms). Inside Groups for example (where you see all the posts one after the other as is the case with the stream, ie it is chronological), they use the timestamping method you described with the auto action and another column for the original activity timestamp.

I've no plans to implement activity bumping, but you can by all means do so using CB Auto Actions. This behavior will be available to Discussion streams when implemented (basically Forums).

Will review making the original activity hide if it's within the grouping time frame (10 days) of the commented on activity. Will then need to review making the menu available and inline edit for the original activity inside the commented on activity functional. This should mean you won't see the original activity entry anymore, removing visible duplication, when it can be grouped.

forge.joomlapolis.com/issues/7170


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.182 seconds

Facebook Twitter LinkedIn