|
@@ -9,8 +9,10 @@ import (
|
|
|
"strings"
|
|
|
. "subrecommend/config"
|
|
|
. "subrecommend/db"
|
|
|
+ "time"
|
|
|
|
|
|
. "app.yhyue.com/moapp/jybase/common"
|
|
|
+ . "app.yhyue.com/moapp/jybase/date"
|
|
|
"app.yhyue.com/moapp/jybase/logger"
|
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
|
)
|
|
@@ -59,27 +61,53 @@ func LoadAllBehavior() map[string]*Behavior {
|
|
|
}
|
|
|
searchfor, _ := (*l)[0]["searchfor"].(string)
|
|
|
browse, _ := (*l)[0]["browse"].(string)
|
|
|
- if searchfor == "" && browse == "" {
|
|
|
- return true
|
|
|
- }
|
|
|
- var searchfors []*Searchfor
|
|
|
+ userId, _ := (*l)[0]["userid"].(string)
|
|
|
+ searchfors := []*Searchfor{}
|
|
|
if searchfor != "" {
|
|
|
- if err := json.Unmarshal([]byte(searchfor), &searchfors); err != nil {
|
|
|
+ searchforsTemp := []*Searchfor{}
|
|
|
+ if err := json.Unmarshal([]byte(searchfor), &searchforsTemp); err != nil {
|
|
|
logger.Error(searchfor, err)
|
|
|
+ } else {
|
|
|
+ for _, v := range searchforsTemp {
|
|
|
+ datetime, err := time.ParseInLocation(Date_Full_Layout, v.Datetime, time.Local)
|
|
|
+ if err != nil {
|
|
|
+ logger.Info(userId, err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if datetime.Before(time.Now().AddDate(0, 0, -Config.SearchLimitDay)) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ searchfors = append(searchfors, v)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- var browses []*Browse
|
|
|
+ browses := []*Browse{}
|
|
|
if browse != "" {
|
|
|
- if err := json.Unmarshal([]byte(browse), &browses); err != nil {
|
|
|
+ browsesTemp := []*Browse{}
|
|
|
+ if err := json.Unmarshal([]byte(browse), &browsesTemp); err != nil {
|
|
|
logger.Error(browse, err)
|
|
|
+ } else {
|
|
|
+ for _, v := range browsesTemp {
|
|
|
+ datetime, err := time.ParseInLocation(Date_Full_Layout, v.Datetime, time.Local)
|
|
|
+ if err != nil {
|
|
|
+ logger.Info(userId, err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ if datetime.Before(time.Now().AddDate(0, 0, -Config.BrowseLimitDay)) {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ browses = append(browses, v)
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ if len(searchfors) == 0 && len(browses) == 0 {
|
|
|
+ return true
|
|
|
+ }
|
|
|
area := ""
|
|
|
if browses != nil && len(browses) > 0 {
|
|
|
area = browses[0].Area
|
|
|
}
|
|
|
- userid, _ := (*l)[0]["userid"].(string)
|
|
|
- allBehavior[userid] = &Behavior{
|
|
|
+ allBehavior[userId] = &Behavior{
|
|
|
Searchfors: searchfors,
|
|
|
Browses: browses,
|
|
|
Area: area,
|