简体   繁体   English

处理提醒电子邮件的正确方法是什么?

[英]What is the proper way to handle reminder emails?

My rails app will send a reminder email if a user has not composed any new posts in three days. 如果用户三天内未撰写任何新帖子,我的Rails应用程序将发送一封提醒电子邮件。 This is defined as a rake task that is scheduled. 这被定义为计划的耙任务。

The task is scheduled every day. 该任务是每天安排的。 Of course, the task should only fire once for every user. 当然,该任务仅应为每个用户触发一次。 A user should get it on the third day and then never again. 用户应在第三天获得,然后再也不会。 On the tenth day, I might fire a totally different email. 在第十天,我可能会发送完全不同的电子邮件。

  • Where and how to let the app know that a user has received the reminder? 如何在哪里以及如何让应用知道用户已收到提醒?
  • Where, when and how to clean out the set "received reminder status" (if the user composes a new post)? 在哪里,何时何地清除设置的“收到的提醒状态”(如果用户撰写新帖子)?
  • How to go about multiple reminder emails (eg after 5, 10, 15 days)? 如何处理多封提醒电子邮件(例如5、10、15天之后)?

I know that adding a column called received_reminder to the user table is an option. 我知道,添加一个名为列received_reminder用户表是一个选项。 When you fire the task, you would change received_reminder to true and clean it out again when a user creates a new post. 当你火了任务,你会改变received_remindertrue和当用户创建一个新的岗位重新清理出来。 Multiple reminders would mean a new column for every reminder. 多个提醒将意味着每个提醒都有一个新列。 Eg received_reminder_5days etc. – this seems not to DRY in opinion and I suspect that there might be a better way generally. 例如, received_reminder_5days等-DRY认为这似乎不可行,我怀疑通常可能会有更好的方法。

What is the best practice in terms of reminder emails? 关于提醒电子邮件的最佳做法是什么?

You even do not need an extra field. 您甚至不需要一个额外的字段。 You can set up an array reminder_days = [3,5,10,15] (for example) and then once a day check whether the age d (in days) of the users last post (which can be obtained from the database) is a member of reminder_days . 您可以设置一个数组reminder_days = [3,5,10,15] (例如),然后每天检查一次用户最近一次发布的年龄d (以天为单位)(可以从数据库中获取) reminder_days的成员。 If it is, you send a reminder. 如果是,则发送提醒。 This reminder is the n+1 th reminder if n is the index of d in the array reminder_days . 如果n是dicker_days数组中d的索引,则此提醒为第n+1reminder_days

To be really safe even in the case that the process of daily sending out reminder emails is interrputed, you could store the numbers of reminders that have already been sent in a field reminder_count . 要想真正安全的,即使在情况下,每天发出提醒邮件的过程interrputed,你可以存储已经在现场发送提醒的数量reminder_count This field is set to 0 whenever the user creates a new post, and it is increased whenever a reminder is sent. 每当用户创建新帖子时,此字段都设置为0;每当发送提醒时,该字段就会增加。 With this field, you can check at any time whether a reminder still needs to be sent today or not (check whether n==reminder_count ). 使用此字段,您可以随时检查是否仍需要今天发送n==reminder_count (检查是否n==reminder_count )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在Rails中处理“类型”的正确方法是什么? - What is the proper way to handle “types” in Rails? 处理在Rails中发送许多电子邮件的最佳方法是什么? - What is the best way to handle sending many emails in Rails? 在 Rails 中验证多封电子邮件和处理错误的最佳方法是什么? - What's the best way to validate multiple emails and handle errors in Rails? 将Rails + Devise用于API时处理电子邮件的最佳方法是什么 - What is the best way to handle emails when using Rails + Devise for an API 在Rails中处理多对多助手视图的正确方法是什么? - what is the proper way to handle many to many helper views in rails? 在Rails中处理Oauth使用者密钥和机密的正确方法是什么? - What is the proper way to handle Oauth Consumer Key and Secret in Rails? 用连接池处理活动记录超时的正确方法是什么? - what's the proper way to handle timeouts for active record with a connection pool? 在Ruby on Rails中处理地理区域设置的正确方法是什么? - What's the proper way to handle geographic locales in Ruby on Rails? 构建用于提醒电子邮件的系统 - Architecting a system for reminder emails 在Rails 2.3.8中处理本地化的命名空间路由的正确方法是什么? - What's the proper way to handle localized name-spaced routes in Rails 2.3.8?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM