0

2 種類のタスクがある単純な todo アプリを作成しています。

1) 定期的なタスク - これらには期日があります 2) 定期的なタスク - これらは、指定された日付にリマインダーとしてポップアップされます。毎週または毎月のリマインダーとして作成できます。1 週間分作成した場合は、毎週 (週の指定日) にポップアップ表示されます。同様に、月の場合は週と日付を指定する必要があります。

このシナリオをモデル化する最良の方法は何ですか?

4

2 に答える 2

2

リマインダー オブジェクトには、remind_at(日付) とrepeat_frequency(さまざまな再発を特定するもの) の 2 つの列があります。そうすれば、remind_at列にインデックスを付けて、非常に迅速に検索できます。リマインダーがユーザーに表示されるたびに、repeat_frequency繰り返しの指示が含まれているremind_at場合は次の日付に設定され、そうでない場合はリマインダーを削除/アーカイブします。

于 2009-11-30T08:52:35.467 に答える
0

You could model a Task to have a due_date. But if a task is recurring, due_date will be null and you would use the recurrence field to compute the next_due_date. recurrence would be a string field holding a parsable string like "tuesday" (for weekly) or "17" (a day number for monthly).

def next_due_date
  if due_date
    due_date
  else
    # compute next due date using the 'recurrence' field and today's date
  end
end

This may or may not be the "best way" for you, depending on your requirements, and the future needs of the model.

于 2009-11-30T19:37:24.797 に答える