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) {
// 4. check if user can do 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 {
log.WithError(err).Error("failed to check free times")
return nil, err
......@@ -116,7 +116,7 @@ func (c *CacheData) Query(path string, uid int64) (*model.TaskType, error) {
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"
layoutMonth := "2006-01"
var (
......@@ -131,8 +131,8 @@ func (c *CacheData) checkQueryForFreeTimes(uid int64, userLevel *model.UserLevel
var (
userDayKey = fmt.Sprintf("k-u-%d:%s:", uid, time.Now().Format(layoutDay))
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))
taskUserMonth = fmt.Sprintf("k-t-%d-u-%d:%s:", taskAndUserLevel.TaskTypeId, uid, time.Now().Format(layoutMonth))
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:", task.ID, uid, time.Now().Format(layoutMonth))
)
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