不断重复直到无穷大

发布于 2024-10-31 20:15:17 字数 311 浏览 6 评论 0原文

假设我想在 ASP.NET MVC 视图中显示提醒(由用户动态创建) 每个星期/每月/......直到“无限”。

对于每个重复发生的情况,此提醒必须是单独的数据库记录(或者在我的例子中为 EF 实体实例对象),因为我在数据库中为每次发生的情况存储特定数据。

你们如何将这些提醒克隆“插入”到数据库中? 我无法插入无限的提醒,..并且选择从现在开始的任意日期说“2000年”似乎是错误的,并且还会将大量记录插入数据库中。

这里有点无能为力......

提前感谢任何(替代)解决方案/建议。 *关键是我可以存储每次发生的数据!*

Let's say I wanted to display a Reminder (dynamically created by user) in my ASP.NET MVC View
Every WEEK/MONTH/.... until "infinity".

This reminder has to be seperate database record (or in my case EF Entity Instance object) for each reocurrence, because i'm storing specific data in my database for each occurrence.

How would you guys go about "inserting" these reminder clones into the database?
I Can't insert infinite reminders, .. And choosing an arbitrary date say "2000 years" from now seems wrong, and also inserts a lot of records into the database.

Kind of clueless here...

Thanks in advance for any (alternative) solution/ advice.
*It is key tough that i can store data for each occurence!*

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难得心□动 2024-11-07 20:15:17

恕我直言,将提醒插入数据库是一种糟糕的实现方式。这只是懒惰。

我的方法是存储条件,然后定期测试条件。也许只是保留上次提醒检查的时间戳,如果超过 8 小时,则重新计算 - 围绕这些线。


更新

为了知道用户是否看到了哪个提醒,对于每种类型,您只需保留读取时间的时间戳。 如果差异大于项目间隔,则必须显示。如果时间戳小于必须显示的时间提醒,则必须显示。

Inserting reminders into the database, IMHO, is a bad way of implementing it. It is just lazy.

My approach would be to store the conditions and then test the conditions on a regular basis. Perhaps just keeping a timestamp of last reminder check and if it is more than 8 hours, re-calculate - something around these lines.


UPDATE

In order to know which reminder has been seen by the user or not, for every type you just keep a timestamp of when it was read. If the difference is more than the item interval, then it must be shown. If timestamp is less than the the time reminder must be shown, then it must be shown.

风启觞 2024-11-07 20:15:17

您的代码在 10 年后被使用的可能性有多大吗?
如果没有尝试10年。

Is there the remotest possibility that your code will be used in 10 years time?
If not try 10 years.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文