Last Posts without 1 User

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
LuigiMdg
Registered User
Posts: 132
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Last Posts without 1 User

Post by LuigiMdg » Sun Jan 14, 2018 12:03 pm

Hi..
I want to find the LAST_POST_AUTHOR but without 1 user.. Because I've an autowriter Robot that write every 5 minutes..
How to exclude this user from search of the last post author in the viewforum_body?
Image

User avatar
warmweer
Registered User
Posts: 972
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: Last Posts without 1 User

Post by warmweer » Sat Jan 20, 2018 7:14 pm

LuigiMdg wrote:
Sun Jan 14, 2018 12:03 pm
I want to find the LAST_POST_AUTHOR but without 1 user.. Because I've an autowriter Robot that write every 5 minutes..
How to exclude this user from search of the last post author in the viewforum_body?
If your autowriter Robot writes every 5 minutes probablility is high that the LAST_POST_AUTHOR will be the Robot, but also the author of the penultimate post, unless you've already blocked the autowriter to reply in a topic where he is already the last poster.
What is it exactly you want to achieve? Is it excluding search results for posts where the LAST_POST_AUTHOR is the robot, or show the latest last post made by a non-robot user in a topic? Or even something else?
This, not because I have a solution, or even an idea, but because the request isn't clear enough (to me). Just a guess, looking at the image: it seems you want to show a list with the post_title of the latest post made by a non-robot user, in each topic. Is that correct?
A bug is a feature that hasn't made it to the manual (yet)

User avatar
LuigiMdg
Registered User
Posts: 132
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Last Posts without 1 User

Post by LuigiMdg » Sat Jan 27, 2018 11:49 am

warmweer wrote:
Sat Jan 20, 2018 7:14 pm
LuigiMdg wrote:
Sun Jan 14, 2018 12:03 pm
I want to find the LAST_POST_AUTHOR but without 1 user.. Because I've an autowriter Robot that write every 5 minutes..
How to exclude this user from search of the last post author in the viewforum_body?
If your autowriter Robot writes every 5 minutes probablility is high that the LAST_POST_AUTHOR will be the Robot, but also the author of the penultimate post, unless you've already blocked the autowriter to reply in a topic where he is already the last poster.
What is it exactly you want to achieve? Is it excluding search results for posts where the LAST_POST_AUTHOR is the robot, or show the latest last post made by a non-robot user in a topic? Or even something else?
This, not because I have a solution, or even an idea, but because the request isn't clear enough (to me). Just a guess, looking at the image: it seems you want to show a list with the post_title of the latest post made by a non-robot user, in each topic. Is that correct?
Exactly..!
The Robot is a normal user in a specific group and he not reply to topics but just create new topics

User avatar
warmweer
Registered User
Posts: 972
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: Last Posts without 1 User

Post by warmweer » Sun Jan 28, 2018 10:04 am

1st remark = why only in viewforum_body.html and not in index_body.html as well?
2nd remark = all it takes (I think) is changing the SQLs in viewforum.php and index.php. But this is no small change since the you would need a completely new SQL to look in each topic to find the last post_id not made by the user_id who is the autowriter, in other words the SQL needs to look into the posts_table.
3rd remark: You last statement might just simplify it since the robot never replies to a topic, in other words al you would need is to exclude topics started by the autowriter Robot and without replies (and then the topics_table would still suffice) and the change to the existing SQL is very small.

Disclaimer: this is all just going from memory and I'ld really have to look into a database to be able to take all situations into account.
A bug is a feature that hasn't made it to the manual (yet)

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2813
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Last Posts without 1 User

Post by kasimi » Sun Jan 28, 2018 11:50 am

The last post information is stored in each forum row, because fetching this information when viewing the forum would be too expensive. When submitting a post, the post's forum row is updated, see the submit_post() function in functions_posting.php. This is what you need to prevent from happening if the user is your bot user. Unfortunately, there is no event to alter or remove these SQL queries against the forums table.

User avatar
LuigiMdg
Registered User
Posts: 132
Joined: Sat Jan 10, 2015 9:12 pm
Contact:

Re: Last Posts without 1 User

Post by LuigiMdg » Mon Jan 29, 2018 12:18 am

warmweer wrote:
Sun Jan 28, 2018 10:04 am
1st remark = why only in viewforum_body.html and not in index_body.html as well?
2nd remark = all it takes (I think) is changing the SQLs in viewforum.php and index.php. But this is no small change since the you would need a completely new SQL to look in each topic to find the last post_id not made by the user_id who is the autowriter, in other words the SQL needs to look into the posts_table.
3rd remark: You last statement might just simplify it since the robot never replies to a topic, in other words al you would need is to exclude topics started by the autowriter Robot and without replies (and then the topics_table would still suffice) and the change to the existing SQL is very small.

Disclaimer: this is all just going from memory and I'ld really have to look into a database to be able to take all situations into account.
1: My error..! I need this in index_body.php
kasimi wrote:
Sun Jan 28, 2018 11:50 am
The last post information is stored in each forum row, because fetching this information when viewing the forum would be too expensive. When submitting a post, the post's forum row is updated, see the submit_post() function in functions_posting.php. This is what you need to prevent from happening if the user is your bot user. Unfortunately, there is no event to alter or remove these SQL queries against the forums table.
What's the table..?
I can insert a simple:

Code: Select all

if($username != ' Robot' || $user_id != 49){

}

User avatar
warmweer
Registered User
Posts: 972
Joined: Fri Jul 04, 2003 6:34 am
Location: Van Allen Belt ... well actually Belgium

Re: Last Posts without 1 User

Post by warmweer » Mon Jan 29, 2018 7:51 am

LuigiMdg wrote:
Mon Jan 29, 2018 12:18 am
...
What's the table..?
I can insert a simple:

Code: Select all

if($username != ' Robot' || $user_id != 49){
}
It's not as simple as you may think.
The forum_table contains info about each forum and it's latest post. If that latest post is by the robot and you exclude it from the search, then that forum will not be found. You would have to take into account that in that specific forum which could not be found, there are other topics (perhaps in other subforums) that have replies by a normal user and one of those topic last replies is then what you want to show on the index.
Plus: the forum_table info should always correspond with the topics_table which naturally corresponds with the posts_table so you can't really touch that without breaking a lot of other stuff.

As kasimi wrote: it's a heavy load to do this in real-time each time the index_page is called.
One way of avoiding that could be to use an alternative "index" page using an alternative (parallel) forums_table but it would have to be perfectly clear exactly what you want to show to your members before anyone could really start on something like this.
A bug is a feature that hasn't made it to the manual (yet)

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2813
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Last Posts without 1 User

Post by kasimi » Mon Jan 29, 2018 5:59 pm

Don't do this on a live board without being absolutely sure it doesn't have any side effects: https://github.com/phpbb/phpbb/blob/rel ... 1915-L1920 Also, adding your if there will not only affect the index page but your entire board.

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests