defstudio / telegraph

Telegraph is a Laravel package for fluently interacting with Telegram Bots
MIT License
674 stars 116 forks source link

replyWebhook() performance issue #568

Closed ah-rahimi closed 5 months ago

ah-rahimi commented 5 months ago

Hi why replyWebhook() function in TelegraphBot model send a query for get all users? image

in the bot() function get all chats (users) to check chat is set: image

why query to the database and get all users? We have a lot of users and that's too bad.

Please remove this, as there is no need for chat in the replyWebhook() function: image

Thanks!

ah-rahimi commented 5 months ago

Can you check this @fabio-ivona? We really have a performance problem...

fabio-ivona commented 5 months ago

fixed

ah-rahimi commented 5 months ago

Hello @fabio-ivona , I want to know why chat is needed here?

And now you send two queries.

fabio-ivona commented 5 months ago

That function automatically loads the chat when a bot has just one

it sends one query to count the bot's chats, if there are more than one, it should not send the second query

ah-rahimi commented 5 months ago

Yes, you are right. But isn't it better to use a chat only where it is needed? Even the count query is heavy.

fabio-ivona commented 5 months ago

I get your point and found a solution

let me know if v1.43.1 solves your issue

ah-rahimi commented 5 months ago

thank you so much I will definitely let you know...