Commit 68876c43 authored by vicotor's avatar vicotor

update bug

parent 8378e971
...@@ -90,7 +90,7 @@ func (c *CacheData) Query(path string, uid int64) (*model.TaskType, error) { ...@@ -90,7 +90,7 @@ func (c *CacheData) Query(path string, uid int64) (*model.TaskType, error) {
// 4. check if user can do this task. // 4. check if user can do this task.
{ {
// a. check free times for this user and this task. // a. check free times for this user and this task.
passed, err := c.checkQueryForFreeTimes(uid, userLevel, userLevelAndTaskType) passed, err := c.checkQueryForFreeTimes(uid, userLevel, task, userLevelAndTaskType)
if err != nil { if err != nil {
log.WithError(err).Error("failed to check free times") log.WithError(err).Error("failed to check free times")
return nil, err return nil, err
...@@ -116,7 +116,7 @@ func (c *CacheData) Query(path string, uid int64) (*model.TaskType, error) { ...@@ -116,7 +116,7 @@ func (c *CacheData) Query(path string, uid int64) (*model.TaskType, error) {
return nil, ErrBalanceNotEnough return nil, ErrBalanceNotEnough
} }
func (c *CacheData) checkQueryForFreeTimes(uid int64, userLevel *model.UserLevel, taskAndUserLevel *model.UserLevelTaskType) (bool, error) { func (c *CacheData) checkQueryForFreeTimes(uid int64, userLevel *model.UserLevel, task *model.TaskType, taskAndUserLevel *model.UserLevelTaskType) (bool, error) {
layoutDay := "2006-01-02" layoutDay := "2006-01-02"
layoutMonth := "2006-01" layoutMonth := "2006-01"
var ( var (
...@@ -131,8 +131,8 @@ func (c *CacheData) checkQueryForFreeTimes(uid int64, userLevel *model.UserLevel ...@@ -131,8 +131,8 @@ func (c *CacheData) checkQueryForFreeTimes(uid int64, userLevel *model.UserLevel
var ( var (
userDayKey = fmt.Sprintf("k-u-%d:%s:", uid, time.Now().Format(layoutDay)) userDayKey = fmt.Sprintf("k-u-%d:%s:", uid, time.Now().Format(layoutDay))
userMonthKey = fmt.Sprintf("k-u-%d:%s:", uid, time.Now().Format(layoutMonth)) userMonthKey = fmt.Sprintf("k-u-%d:%s:", uid, time.Now().Format(layoutMonth))
taskUserDayKey = fmt.Sprintf("k-t-%d-u-%d:%s:", taskAndUserLevel.TaskTypeId, uid, time.Now().Format(layoutDay)) taskUserDayKey = fmt.Sprintf("k-t-%d-u-%d:%s:", task.ID, uid, time.Now().Format(layoutDay))
taskUserMonth = fmt.Sprintf("k-t-%d-u-%d:%s:", taskAndUserLevel.TaskTypeId, uid, time.Now().Format(layoutMonth)) taskUserMonth = fmt.Sprintf("k-t-%d-u-%d:%s:", task.ID, uid, time.Now().Format(layoutMonth))
) )
pip := c.rdb.Pipeline() pip := c.rdb.Pipeline()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment