Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bxy4543 committed Sep 27, 2024
1 parent e4012a3 commit 44b7864
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
9 changes: 3 additions & 6 deletions controllers/pkg/database/cockroach/accountv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,13 @@ func (c *Cockroach) getTask() (map[uuid.UUID]types.Task, error) {

func (c *Cockroach) getPendingRewardUserTask() ([]types.UserTask, error) {
var userTasks []types.UserTask
return userTasks, c.DB.Where(&types.UserTask{Status: types.TaskStatusCompleted}).
Where(`"rewardStatus" = ? OR "rewardStatus" = ?`, types.RewardStatusPending, "").
return userTasks, c.DB.Where(&types.UserTask{Status: types.TaskStatusCompleted, RewardStatus: types.TaskStatusNotCompleted}).
Find(&userTasks).Error
}

func (c *Cockroach) completeRewardUserTask(tx *gorm.DB, userTask *types.UserTask) error {
userTask.CompletedAt = time.Now().UTC()
userTask.UpdatedAt = time.Now().UTC()
userTask.RewardStatus = types.RewardStatusCompleted
return tx.Model(userTask).Update("rewardStatus", types.RewardStatusCompleted).Error
userTask.RewardStatus = types.TaskStatusCompleted
return tx.Model(userTask).Update("rewardStatus", types.TaskStatusCompleted).Error
}

func (c *Cockroach) GetUserCr(ops *types.UserQueryOpts) (*types.RegionUserCr, error) {
Expand Down
19 changes: 7 additions & 12 deletions controllers/pkg/types/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type UserTask struct {
UserUID uuid.UUID `gorm:"column:userUid;type:uuid;not null" json:"userUid"`
TaskID uuid.UUID `gorm:"column:taskId;type:uuid;not null" json:"taskId"`
Status TaskStatus `gorm:"column:status;type:TaskStatus;not null" json:"status"`
RewardStatus string `gorm:"column:rewardStatus;type:text;not null" json:"rewardStatus"`
RewardStatus TaskStatus `gorm:"column:rewardStatus;type:TaskStatus;not null" json:"rewardStatus"`
CompletedAt time.Time `gorm:"column:completedAt;type:timestamp(3);not null" json:"completedAt"`
CreatedAt time.Time `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp();not null" json:"createdAt"`
UpdatedAt time.Time `gorm:"column:updatedAt;type:timestamp(3) with time zone;not null" json:"updatedAt"`
Expand All @@ -64,12 +64,12 @@ func (UserTask) TableName() string {
// TaskType represents the TaskType enum in Go.
type TaskType string

const (
TaskTypeLaunchpad TaskType = "LAUNCHPAD"
TaskTypeCostcenter TaskType = "COSTCENTER"
TaskTypeDatabase TaskType = "DATABASE"
TaskTypeDesktop TaskType = "DESKTOP"
)
//const (
// TaskTypeLaunchpad TaskType = "LAUNCHPAD"
// TaskTypeCostcenter TaskType = "COSTCENTER"
// TaskTypeDatabase TaskType = "DATABASE"
// TaskTypeDesktop TaskType = "DESKTOP"
//)

// TaskStatus represents the TaskStatus enum in Go.
type TaskStatus string
Expand All @@ -78,8 +78,3 @@ const (
TaskStatusNotCompleted TaskStatus = "NOT_COMPLETED"
TaskStatusCompleted TaskStatus = "COMPLETED"
)

const (
RewardStatusCompleted = "COMPLETED"
RewardStatusPending = "PENDING"
)
2 changes: 1 addition & 1 deletion service/account/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func RegisterPayRouter() {
}

func startRewardProcessingTimer(ctx context.Context) {
ticker := time.NewTicker(1 * time.Minute)
ticker := time.NewTicker(30 * time.Second)
defer ticker.Stop()
for {
select {
Expand Down

0 comments on commit 44b7864

Please sign in to comment.