process remind to user on exact date and time in django - django

So I have notification system in place.For example when sending a task to user, user get a notification within my system. Right now I have only "instant" notifications. so when I send a task to someone, a notification is created in the db, and via web-socket the user is notified with the data of the notification.
With the Reminder I have the problem, that the notification I want to send here is not necessarily "instant". I want to set the date to next Monday on 9 am. so User should receive the notification on Monday 9 am.
Question: Is there an extension in django (or onboard methods) where I can execute stuff delayed? For example, send notification with the following data on Monday 9 am.

Celery can be used to schedule and defer tasks.
Here's and example of how to schedule for a specific time. https://docs.celeryq.dev/en/latest/userguide/calling.html#eta-and-countdown

Related

Cron for sending emails after 3 days in django

I dont have any knowledge about the cron. In my project once the task is assigned to employee email is sent to his mailid. If the employee does not complete the task within deadline I want to send the mail after every 3 days to complete the task. Can anyone give me I idea what I should do. The project is on my local environment, does it support or I should take server.
apscheduler would do the job
It would look like this
bg_scheduler = BackgroundScheduler()
bg_scheduler.add_job(send_email, 'interval', days=3)
bg_scheduler.start()

Building Alexa Skill that pushes an alarm

I'm trying to build an alexa skill that fires a custom alarm every set number of times per day (30 min intervals for example). I'm reading through their docs and not fulling understanding where to go to next.
Does anyone have some good Alexa skill apps that I can reference or an article? I couldn't find much online and it looks like it hasn't been an accessible feature for too long.
You cannot trigger Alexa to speak without user interaction. That means, the user has to say something to trigger your skill, which will in turn create a request to you skill's backend, and you can only respond (be it audio or speech) back to that request.
However, you can send Push Notifications.
Notification indicators inform end users that new content is available
from Alexa skills and domains. When a notification is delivered,
depending on what the product is capable of, the user is notified by
visual and audio indicators.
More on Push Notification here

Django: Send reminder email

my app has list of events with start time (date and time). I want to make a scheduled task to send reminder via email to all user participate in event 1 hour before event start. (Note: Admin can change time of event).
I currently use celery to send email to list of participants when admin change the time of event.
Please suggest me some solution for this. Thanks.
Here's a recent(ish) discussion where a potential solution is proposed for celery: https://github.com/celery/celery/issues/4522.
I built Posthook to make solving these kinds of problems easier for developers. In your case, when a new event is created or the event time changes you can schedule a request back to your app for 1 hour before the start time. Then when you get the request from Posthook you can send out the reminder after validating that it still needs to be sent out.

Google Admin SDK user push notifications and renaming of users

I want to ask about the situation that is related to the renaming of a user by an administrator. It can take up to 10 minutes (from the disclaimer) to get user's name changed, but the notification about update event is sent immediately. There is no way to understand whether user's data is changed or not at the moment when notification is received. The only way to process it correctly is to delay processing by 10 minutes which is not good for me.
Is there something that I've missed to handle this? Otherwise it is quite useless API.

Using Timers/Signals to allow human intervention in AWS SWF Workflow

Here's the scenario. A user uploads an Excel file and this kicks off a workflow which validates the file, transforms it into a few different files, then performs an update to a database based on the transforms. After the uploads, the results need to be reviewed by team member before the flow can continue.
I'm using Ruby and have discovered that Signals and Timers are the way to achieve this in SWF. However, the Ruby examples are lacking or non-existent and I need a little help understanding how this would work using Ruby.
Ny understanding so far is that a Timer activity is scheduled which basically pauses the flow until either the timer expires (at which point I could cancel the workflow or email the staff and set another timer) or a signal is sent to the workflow to start the next step. The Decider would handle the signal and then kick off the appropriate activity.
Any thoughts or direction to other sources would be much appreciated.
Thanks,
Thomas
It's somewhat difficult to provide an "answer", given you didn't really ask a specific question. I'm in agreement with you that using a Timer and Signals is what you want.
You don't specify how the team gets notified about the review. I'll assume that you notify them by email and direct them to some website where they can review the changes, and then click on a link to either Approve or Don't Approve. Clicking the link to Approve will send a request to a web server that will "signal" SWF that the review has been approved. Clicking the link to Don't Approve will "signal" SWF that the review has not been approved. You mention that you want to renotify the team (or perhaps escalate to the manager) if no one has taken action on the review. Let's say this renotification happens after 48 hours. After the renotication, you grant them another 72 hours before assumming Don't Approve.
Here's how your workflow looks like to me:
User uploads file and kicks off a workflow
Decider Task schedules "TransformActivity"
TransformActivity runs, transforms the data into different files, and completes successfully
Decider Task schedules "UpdateDatabaseActivity"
UpdateDatabaseActivity runs, updates the database, and completes successfully
Decider Task schedules "EmailTeamActivity"
EmailTeamActivity runs, emails the team, and completes successfully
Decider Task schedules a Timer for 48 hours.
If a signal indicating Approve or Don't Approve is received within 48 hours:
Decider Task schedules the "RecordFinalDecisionActivity"
RecordFinalDecisionActivity will run, record the Approve (or Don't Approve) into the database, and complete successfully.
Decider Task will then close the workflow because it's done.
If no signal is received and the timer fires (after 48 hours):
Decider Task schedules the "EmailTeamAndManagerActivity"
EmailTeamAndManagerActivity runs, emails the team and manager, and completes successfully.
Decider Task schedules another timer for 72 hours.
If a signal indicating Approve or Don't Approve is received within the additional 72 hours given:
Repeat the same logic as the section "If a signal indicating Approve or Don't Approve is received within 48 hours".
If no signal is received and the timer fires (after the additional 72 hours):
At this point, the workflow can assume it was a Don't Approve, schedule the "RecordFinalDecisionActivity" and close the workflow once that activity completes.
The reason why you don't want to have a "review" activity is because that task gets scheduled and then some activity worker needs to reply success. How would that work? When someone clicks the Approve or Don't Approve link, the request to the webserver would have to pull down the activity from the task list. However, if the task list has multiple activities, SWF just gives out any one of them. It might not get the right one. Now, you could argue that you could schedule the different reviews across different task lists, but that's just cumbersome and tedious.
Signals are done to indicate an "external" event, which this very much is. The SWF documentation on Signals does a great job on talking about Signals. Here's the SWF documentation on how to use Timers and Signals. As for the particulars on how to use SWF and Ruby, I can't really help you there. I've only used SWF with Java by using the AWS Flow Framework.
user upload excel file, does "StartWorkflowExecution", that queues a decision task
decision worker notice flow is new / "stage one", it schedules "transform file" activity task
activity worker picks up task, and does the "transform file" activity, when done does "RespondActivityTaskCompleted" with a result of "transformations done", that queues a decision task
decision worker picks up decision task, notices the transformations are done and schedule a new activity task
activity worker picks up activity task, notices it's for a team member (according to the instructions given by the decision worker when scheduling the activity task), team member gets notified, somehow perform his action, then somehow notifies the activity worker which will reply "RespondActivityTaskCompleted"
I don't see the need for a Timer or a Signal, it's just plain flow. Those two concepts are useful if you want recurring events, timeouts, and/or interrupting the flow.
Please note that you can differentiate activity workers by using task lists (for example activity workers for automated work vs activity workers for human participants, whatever).