本来の期限に加えて自分の中での目標期限を設定できるよう仕様追加

This commit is contained in:
2026-04-23 09:40:18 +09:00
parent b2dd70cf27
commit 098f636a65
11 changed files with 151 additions and 32 deletions

View File

@@ -14,6 +14,7 @@ type Assignment struct {
Subject string `json:"subject"`
Priority string `gorm:"not null;default:medium" json:"priority"`
DueDate time.Time `gorm:"not null" json:"due_date"`
SoftDueDate *time.Time `json:"soft_due_date,omitempty"`
IsCompleted bool `gorm:"default:false" json:"is_completed"`
IsArchived bool `gorm:"default:false;index" json:"is_archived"`
CompletedAt *time.Time `json:"completed_at,omitempty"`
@@ -23,7 +24,6 @@ type Assignment struct {
UrgentReminderEnabled bool `gorm:"default:true" json:"urgent_reminder_enabled"`
LastUrgentReminderSent *time.Time `json:"last_urgent_reminder_sent,omitempty"`
// Recurring assignment reference
RecurringAssignmentID *uint `gorm:"index" json:"recurring_assignment_id,omitempty"`
RecurringAssignment *RecurringAssignment `gorm:"foreignKey:RecurringAssignmentID" json:"-"`
@@ -34,6 +34,13 @@ type Assignment struct {
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
}
func (a *Assignment) GetEffectiveSoftDueDate() time.Time {
if a.SoftDueDate != nil {
return *a.SoftDueDate
}
return a.DueDate.Add(-48 * time.Hour)
}
func (a *Assignment) IsOverdue() bool {
return !a.IsCompleted && time.Now().After(a.DueDate)
}