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

changed dialog checking and new day to periodic tasks #91

Merged
merged 2 commits into from
Jun 2, 2023

Conversation

wbaccinelli
Copy link
Contributor

@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@wbaccinelli wbaccinelli requested a review from raar1 June 2, 2023 12:07
Copy link
Contributor

@raar1 raar1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK this looks cleaner than before :) I assume using celery's periodic tasks is more robust than the async stuff from before?

@@ -68,16 +64,12 @@ def check_dialogs_status(self): # pylint: disable=unused-argument
fsm.dialog_state.set_to_idle()
save_state_machine_to_db(fsm)

next_day = datetime.now().replace(hour=10, minute=00) + timedelta(days=1)
next_day = datetime.now().replace(hour=00, minute=00) + timedelta(days=1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new day used to start at 10am?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but it didn't make a lot of sense. I mean, I am not yet so lucky to be in the position of denying the existence of the early morning hours XD

## TODO: uncomment and solve issue
# check_dialogs_status.apply_async()
sender.add_periodic_task(crontab(hour=00, minute=00), notify_new_day.s(datetime.today()))
sender.add_periodic_task(MAXIMUM_DIALOG_DURATION, check_dialogs_status.s())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something I'm wondering about - I think we configured Celery to use the redis key-value store for storing its tasks. If the current docker-compose setup goes down, the contents of that store are lost, so on restarting the app it should be completely clear (no celery tasks set at all). So the app initially sets up every celery task it needs just from reading the db. Is this the correct way to understand it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very good point, and it might be a problem if we want, for example, to update the system. At the moment the app sets up just recurrent tasks for checks that need to be done periodically, but it doesn't restore the scheduled tasks that have not been executed. This information is in the DB, so we "just" need to read the info from there. I opening an issue for that.

@wbaccinelli wbaccinelli merged commit 00f7e61 into main Jun 2, 2023
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.

Change notify_new_day and Check_dialog_status to periodic tasks
2 participants