aboutsummaryrefslogtreecommitdiffstats
path: root/internal/chore
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-08-10 00:24:15 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-08-10 00:24:15 -0400
commitce3ee9e9dcb59138d830b52c26dc584883a7fe1f (patch)
tree4b0a44194a10bf9bc1b0ab199d88ccc11138d469 /internal/chore
parenta65da84f08927bf6cf62b24245dbde7cf45c505e (diff)
downloaddonetick-ce3ee9e9dcb59138d830b52c26dc584883a7fe1f.tar.gz
donetick-ce3ee9e9dcb59138d830b52c26dc584883a7fe1f.tar.bz2
donetick-ce3ee9e9dcb59138d830b52c26dc584883a7fe1f.zip
Update FrequencyType to use enum in Chore and ChoreReq struct
Diffstat (limited to 'internal/chore')
-rw-r--r--internal/chore/handler.go2
-rw-r--r--internal/chore/model/model.go18
2 files changed, 18 insertions, 2 deletions
diff --git a/internal/chore/handler.go b/internal/chore/handler.go
index 16c80ef..01490cc 100644
--- a/internal/chore/handler.go
+++ b/internal/chore/handler.go
@@ -33,7 +33,7 @@ type ThingTrigger struct {
type ChoreReq struct {
Name string `json:"name" binding:"required"`
- FrequencyType string `json:"frequencyType"`
+ FrequencyType chModel.FrequencyType `json:"frequencyType"`
ID int `json:"id"`
DueDate string `json:"dueDate"`
Assignees []chModel.ChoreAssignees `json:"assignees"`
diff --git a/internal/chore/model/model.go b/internal/chore/model/model.go
index 38d8354..b2633b3 100644
--- a/internal/chore/model/model.go
+++ b/internal/chore/model/model.go
@@ -6,10 +6,26 @@ import (
tModel "donetick.com/core/internal/thing/model"
)
+type FrequencyType string
+
+const (
+ FrequancyTypeOnce FrequencyType = "once"
+ FrequancyTypeDaily FrequencyType = "daily"
+ FrequancyTypeWeekly FrequencyType = "weekly"
+ FrequancyTypeMonthly FrequencyType = "monthly"
+ FrequancyTypeYearly FrequencyType = "yearly"
+ FrequancyTypeAdaptive FrequencyType = "adaptive"
+ FrequancyTypeIntervel FrequencyType = "interval"
+ FrequancyTypeDayOfTheWeek FrequencyType = "days_of_the_week"
+ FrequancyTypeDayOfTheMonth FrequencyType = "day_of_the_month"
+ FrequancyTypeTrigger FrequencyType = "trigger"
+ FrequancyTypeNoRepeat FrequencyType = "no_repeat"
+)
+
type Chore struct {
ID int `json:"id" gorm:"primary_key"`
Name string `json:"name" gorm:"column:name"` // Chore description
- FrequencyType string `json:"frequencyType" gorm:"column:frequency_type"` // "daily", "weekly", "monthly", "yearly", "adaptive",or "custom"
+ FrequencyType FrequencyType `json:"frequencyType" gorm:"column:frequency_type"` // "daily", "weekly", "monthly", "yearly", "adaptive",or "custom"
Frequency int `json:"frequency" gorm:"column:frequency"` // Number of days, weeks, months, or years between chores
FrequencyMetadata *string `json:"frequencyMetadata" gorm:"column:frequency_meta"` // Additional frequency information
NextDueDate *time.Time `json:"nextDueDate" gorm:"column:next_due_date;index"` // When the chore is due