Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pause / resume functionality #1102

Closed
wants to merge 10 commits into from
Closed

Pause / resume functionality #1102

wants to merge 10 commits into from

Conversation

asafov
Copy link

@asafov asafov commented May 26, 2020

Pause / resume functionality for #1099

@asafov
Copy link
Author

asafov commented May 26, 2020

Call example:
$this->conversation = new Conversation($chatId, $chatId, $this->getName(), true);

@noplanman
Copy link
Member

Thanks for the PR @asafov

I've noticed that you've worked on the master branch and pointed this PR to master as well.

As all work is done on the develop branch and only finished releases go into master, please rebase your commits (onto the develop branch) and change the PR to point to develop.

🙏

Looking forward to give this a test afterwards 😃

@asafov asafov changed the base branch from master to develop May 26, 2020 12:50
@asafov
Copy link
Author

asafov commented May 26, 2020

Thanks for the PR @asafov

I've noticed that you've worked on the master branch and pointed this PR to master as well.

As all work is done on the develop branch and only finished releases go into master, please rebase your commits (onto the develop branch) and change the PR to point to develop.

Looking forward to give this a test afterwards

Done.

@noplanman
Copy link
Member

As far as i recall how conversations are set up, there can only be 1 conversation per user per command, so there can never be multiple conversations happening for the same command.
For this reason, the state of a conversation can only be a single state, never multiple ones.

With that in mind, a paused conversation is the same like an active one, but with a paused status. So when requesting a conversation, there is no need to know in which state the conversation is in, as there will only be 1 to return anyway, and then the state can be read from that.

So looking at the PR, it seems that most of the extra code for the paused status isn't necessary and can be accomplished much more easily.

If I've missed something or have it wrong, please explain 🙏

@asafov
Copy link
Author

asafov commented May 27, 2020

So when user start conversation just get active or paused like this?

WHERE (status = :status OR status = :pstatus)
....
$sth->bindValue(':status', 'active');
$sth->bindValue(':pstatus', 'paused');

@noplanman
Copy link
Member

@asafov Looking better indeed 👍

Just a few things:

  1. When pausing and resuming, the conversation doesn't need to be cleared, as that unnecessarily re-fetches all data from the DB.
  2. When updating the status, the status of the $conversation array need to be updated too (as it wouldn't be reloaded after changing point 1.)

Looking at the conversation feature in general, I think it would be great to export it into a separate little package and redesign it a bit. For instance, having the $conversation variable seems a bit weird and it probably makes sense to extract all data directly into the Conversation class, to not have that second layer.

What do you think?

We could then also extend the class to have getStatus or even isActive/isPaused methods.

@asafov
Copy link
Author

asafov commented Jun 3, 2020

All fixes it applied. Can anybody check it?

@asafov
Copy link
Author

asafov commented Jun 6, 2020

Guys?

@noplanman
Copy link
Member

@asafov I've updated the code a tiny bit, could you have a look please?

If all is ok with your tests, we can get this merged 💪

@noplanman
Copy link
Member

noplanman commented Jun 22, 2020

After some deliberation, it looks like the conversations don't need a pause state per se.

What should be updated though, is to allow parallel commands to be active, 1 per command.
At the moment any active conversation gets cancelled when a new one is started.

Also it would make sense to extract the conversations into a separate package entirely.

Thanks @asafov for your input on this 🙏

@noplanman noplanman closed this Jun 22, 2020
@megagosha megagosha mentioned this pull request Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants